How do I disable right-click on images?

Earlier today, I posted ways you could get around people stealing your images. That post was focused on code that could be added to prevent users pinning your images to Pinterest.

Users that don’t want to mess around with their themes, can always install the NoPin WordPress Plugin created by Shawn Hooper. It can also be found on the WordPress Addon site; NoPin WordPress Plugin.

Interestingly enough, the script that Pinterest provided doesn’t seem to work with all WordPress themes. With some of the themes, I was still able to copy to Pinterest without an issues. A bit of research, and it seems that it might not work in some themes.

So… how are you going to keep people from copying your images? One workaround is disabling right click on your images. For a free dhtml script, I used the disable right click on images code, that’s located at Dynamic Drive.

How do I disable right click on my WordPress site?

  1. Click on Appearance tab
  2. Click on Editor
  3. Click on Footer (footer.php)
  4. Insert the code, listed below, on the line right above the </body> tag
<script language="JavaScript1.2">

/*
Disable right click script II (on images)- By
Dynamicdrive.com
For full source, Terms of service, and
100s DTHML scripts
Visit http://www.dynamicdrive.com
*/

var clickmessage="Right click disabled on images!"

function disableclick(e) {
if (document.all) {
if (event.button==2||event.button==3) {
if (event.srcElement.tagName=="IMG"){
alert(clickmessage);
return false;
}
}
}
else if (document.layers) {
if (e.which == 3) {
alert(clickmessage);
return false;
}
}
else if (document.getElementById){
if (e.which==3&&e.target.tagName=="IMG"){
alert(clickmessage)
return false
}
}
}

function associateimages(){
for(i=0;i<document.images.length;i++)
document.images[i].onmousedown=disableclick;
}

if (document.all)
document.onmousedown=disableclick
else if (document.getElementById)
document.onmouseup=disableclick
else if (document.layers)
associateimages()
</script>

For those that don’t want to install the above code, you can always pick up a wordpress addon that disables right clicking images; no right click plugin.

I’ve checked out both the code, and the plin in. Thus far, both have worked with various themes (10 thus far) that I’ve tried.

Because right click has been disabled, most users who use sites such as Pinterest, won’t be able to right click your image and pin on their board. It won’t stop all the copying, but it will decrease the amount that’s copied without permission. As mentioned in the post, how to disable our images from being pinned to Pinterest, a technically advanced user will still be able to copy your images.