To Remove Download Option On The Video Block in WordPress To Secure Your Video Content and Enhance Your Website’s Professionalism.
Video content can be a vital part of your website, but unauthorized downloads can lead to your content being redistributed without your permission. Protecting your videos by disabling the download option is crucial. This guide will help you achieve that, ensuring your videos stay secure and only accessible through your site.
Why Disable the Download Option?
Before we delve into the technical steps, let’s discuss why you might want to disable the download option on your WordPress videos:
- Content Protection: Prevent unauthorized distribution of your intellectual property.
- Control: Ensure your content is viewed in the context you intend.
- Monetization: Protect revenue streams if you offer paid content.
- User Experience: Maintain a consistent user experience by keeping content on your site.
Step-by-Step Guide to Removing the Download Option
Step 1: Using a Secure Video Hosting Service
One of the most straightforward methods is using a third-party video hosting service that offers advanced security features. Services like Vimeo and Wistia allow you to disable the download option.
- Upload Your Video: First, upload your video to a platform like Vimeo or Wistia.
- Adjust Privacy Settings: Go to the video’s settings and disable the download option.
- Embed the Video: Copy the embed code provided by the platform and paste it into your WordPress post or page using the Custom HTML block.
This method ensures users cannot download your videos directly from your site.
Step 2: Modifying WordPress Video Block Settings
For those who prefer to host videos directly on WordPress, a bit of custom code can help disable/remove download option.
- Edit Functions.php File: Navigate to Appearance > Theme Editor and open your theme’s
functions.php
file. - Insert Custom Code: Add the following code snippet to hide the download button in the video controls:
<?php
/**
* Ensure download option is hidden on all core video blocks
*/
add_filter( 'render_block', 'wd_video_block_render', 10, 2 );
function wd_video_block_render( $output, $block ) {
// make sure this only runs on the core/video block
if ( 'core/video' !== $block['blockName'] ) {
return $output;
}
// use str_replace to add controlslist nodownload markup
$output = str_replace(
'<video controls',
'<video controls controlslist="nodownload"', $output
);
//return
return $output;
}
This CSS code effectively remove download option from the video controls.
Step 3: Using WordPress Plugins
Several plugins are designed to enhance video security on WordPress. Plugins like “Prevent Direct Access” or “WP Video Lightbox” can help.
- Install the Plugin: Go to Plugins > Add New, search for the plugin, install, and activate it.
- Configure Plugin Settings: Follow the plugin’s setup instructions to disable the download option for your videos.
ng a more personalized and effective optin process. Follow the steps outlined in this guide to set up your customized opt-in forms and watch your subscriber list grow.
Removing all video controls
The snippet below uses the same method, but adds some additional markup that will remove the three dots and all also remove download option that reside within it:
<?php
/**
* Ensure download options are hidden on all core video blocks
*/
add_filter( 'render_block', 'wd_video_block_render', 10, 2 );
function wd_video_block_render( $output, $block ) {
// make sure this only runs on the core/video block
if ( 'core/video' !== $block['blockName'] ) {
return $output;
}
// use str_replace to add controlslist options to remove three dots
$output = str_replace(
'<video controls',
'<video controls controlslist="nodownload noplaybackrate noremoteplayback" disablePictureInPicture', $output
);
//return
return $output;
}
As you can see, I’ve added some additional markup to the output that will remove the playbackrate
removeplayback
and PictureInPicture
options, which in turn removes the three dots UI completely.
Conclusion
By following these steps, you can successfully remove the download option on the video block in WordPress, protecting your valuable video content. Whether you choose to use a third-party video hosting service, add custom code, or install a dedicated plugin, each method provides a reliable way to secure your videos.
Remember, safeguarding your content not only protects your intellectual property but also enhances your site’s professionalism and user experience. Implement these changes today and keep your video content safe and secure
You could extend this as needed to add any other modifications you’d like to the html5 video markup.