use this:
https://wordpress.org/plugins/disable-embeds/
Or add this to the functions.php file in your child theme:
function disable_embeds_code_init() {
// Remove the REST API endpoint.
remove_action( 'rest_api_init', 'wp_oembed_register_route' );
// Turn off oEmbed auto discovery.
add_filter( 'embed_oembed_discover', '__return_false' );
// Don't filter oEmbed results.
remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 );
// Remove oEmbed discovery links.
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
// Remove oEmbed-specific JavaScript from the front-end and back-end.
remove_action( 'wp_head', 'wp_oembed_add_host_js' );
add_filter( 'tiny_mce_plugins', 'disable_embeds_tiny_mce_plugin' );
// Remove all embeds rewrite rules.
add_filter( 'rewrite_rules_array', 'disable_embeds_rewrites' );
// Remove filter of the oEmbed result before any HTTP requests are made.
remove_filter( 'pre_oembed_result', 'wp_filter_pre_oembed_result', 10 );
}
add_action( 'init', 'disable_embeds_code_init', 9999 );
function disable_embeds_tiny_mce_plugin($plugins) {
return array_diff($plugins, array('wpembed'));
}
function disable_embeds_rewrites($rules) {
foreach($rules as $rule => $rewrite) {
if(false !== strpos($rewrite, 'embed=true')) {
unset($rules[$rule]);
}
}
return $rules;
}
Thanks so much. I really appreciate the code.
But I was actually referring to the new behavior for “File” blocks in the Gutenberg editor
Example of Default File Embed Setting
@stevebab Did you manage to find a way to disable the “Show inline embed” functionality?
Unfortunately, no. I’m sure an override must be possible … I tried to mod the core files responsible for the “file” block, even changing the default xml file for file blocks to set that boolean to
default: “false”
but that didn’t have any affect.
Wish someone would provide a bit more documentation on these changes. I couldn’t find a changelog where this update was listed … Very frustrating and extremely time-consuming for many of my site editors…
I’m also interested to see this as an option. Maybe to be able to set it via theme.json ? Unfortunately it seems its now not possible to override since wordpress’s code set the attribute to true when the file type is pdf:
File: wp-includes/js/dist/block-library.js . See “displayPreview”
function onSelectFile(newMedia) {
if (newMedia && newMedia.url) {
setHasError(false);
const isPdf = newMedia.url.endsWith('.pdf');
setAttributes({
href: newMedia.url,
fileName: newMedia.title,
textLinkHref: newMedia.url,
id: newMedia.id,
displayPreview: isPdf ? true : undefined,
previewHeight: isPdf ? 600 : undefined
});
}
-
This reply was modified 4 years, 8 months ago by
jorinde88.
I’m hoping this default can be disabled too! I’ve built templates for my users to update or generate pages, and every time they replace a PDF file in the listing it automatically changes it from a file link to an embedded PDF view
I don’t know if I would be allowed to add to the github so I’m putting it here; would it also be possible to make so that you can choose for the PDF to display inline on desktop but not on mobile (because it doesn’t work properly on mobile).
Thanks