Jump to content

Jetpack: remove External Media from the block editor


Root
 Share

Recommended Posts

The Jetpack plugin comes with a number of blocks and editor extensions. One of those features extends the existing Media blocks, and adds an option to find and upload images from Google Photos or Pexels:

2031046654_block-editor-insert-media-jetpack-external-media(1).thumb.png.1db9f47b7df8d326ad92c7154ebbf97b.png

While this can be super useful when you use Google Photos or need to find free stock photos for your posts, you may sometimes prefer to only see the default “Media Library” option. but no option to disable this function.

To do so, you can add the following snippet to a functionality plugin on your site:

add this code below wp-config.php

/**
 * Remove Jetpack's External Media feature.
 */
add_action(
    'enqueue_block_editor_assets',
    function () {
        $disable_external_media = <<<JS
document.addEventListener( 'DOMContentLoaded', function() {
    wp.hooks.removeFilter( 'blocks.registerBlockType', 'external-media/individual-blocks' );
    wp.hooks.removeFilter( 'editor.MediaUpload', 'external-media/replace-media-upload' );
} );
JS;
        wp_add_inline_script( 'jetpack-blocks-editor', $disable_external_media );
    }
);

 

  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recent Achievements

    • Hamlo went up a rank
      Contributor
    • Hamlo went up a rank
      Explorer
    • Hamlo went up a rank
      Apprentice
×
×
  • Create New...