Skip to content

Instantly share code, notes, and snippets.

@AntonioLeutsch
Created June 15, 2022 18:56
Show Gist options
  • Save AntonioLeutsch/b067d25b4b88d59df5dce4bf22d63b43 to your computer and use it in GitHub Desktop.
Save AntonioLeutsch/b067d25b4b88d59df5dce4bf22d63b43 to your computer and use it in GitHub Desktop.
Disable Download for Audio & Video
function hide_download_buttons_on_embeds_render_block( $block_content, $block ) {
if ( 'core/audio' === $block['blockName'] ) {
$block_content = str_replace(
'<audio ',
'<audio controlsList="nodownload" ',
$block_content
);
}
if ( 'core/video' === $block['blockName'] ) {
$block_content = str_replace(
'<video ',
'<video controlsList="nodownload" ',
$block_content
);
}
return $block_content;
}
add_filter( 'render_block', 'hide_download_buttons_on_embeds_render_block', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment