Image Protection with jQuery

Once an image is publicly available on the internet, there are many ways to make a local copy of it. There are also a number of ways that try to prevent such unauthorized downloads. Preventing right click / save of the image is most likely the easiest way to protect the casual drive-by image theft. How to incorporate it within a Drupal theme? 5 lines of code.

Within the theme directory, create (if it doesn't exist) or edit script.js. This file will be loaded automatically with the rest of the Drupal jQuery.

$(document).ready(function(){
	$('img').bind("contextmenu",function(){
		return false;
	});
});

Clear caches, refresh the page and your images are protected from right-click downloads. The 'img' can be also replaced with other HTML tags as necessary.

Share this post