How to disable right click on a wordpress photography website?

Since you are on this page, you basically want to disable the right click functionality of the mouse to prevent users from straight away right clicking and downloading your images. It is basically a simple technique to discourage people from easily copying your photos.

We should warn you that no matter what you do, there is no fool-proof way of preventing photo-theft. We have written elaborately on this topic in our previous article here. There are always ways to circumvent things like ‘right click disable’. For example, the user can simply take a screenshot of the page. Or, they can enter the developer tools functionality of a website and then disable the script preventing the right click. Or, they can simply open your site from a browser with disabled Javascript functionality.

If you want to 100% prevent people from copying your photos without your permission, then don’t post them online at all. That said, if all you want is to deter people from trying to copy, then you can follow our guide below.

 

Disable right click using Javascript

This is probably the best solution. All you need to do is place this code in the footer.php file of your WordPress theme. [Click on Appearance button in WordPress admin panel, then click editor, then click footer.php, and then copy-paste this code.]

Alternatively, some themes have an option to keep scripts in the ‘theme options section’, you can keep this code there too.[It is usually under Appearance button in WordPress admin panel too.]

<script>

document.oncontextmenu = function(e){
var target = (typeof e !=”undefined”)? e.target: event.srcElement
if (target.tagName == “IMG” || (target.tagName == ‘A’ && target.firstChild.tagName == ‘IMG’))
return false

}

</script>

This code will let you disable right click ONLY on images/photos.

 

Disable right click using WordPress plugin

The right click functionality of your mouse can also be disabled by installing a WordPress plugin.

WP Content Copy Protection & No Right Click

This is the most popular WordPress plugin to disable right click in WordPress. It is very easy to use. All you need to do is, install the plugin via the WordPress dashboard, and you are ready to go! It can even show a copyright message if someone right clicks on your website.

Right Click Disable Orignal

This is an alternative plugin for the same purpose.

Conclusion

There are a lot of ways to disable right clicks, but no way is fool proof, so, we do not recommend disabling right click as a means to protect your photos. Better add a copyright

Leave a Reply