 

 [    ](https://www.facebook.com/sharer/sharer.php?u=https://www.skvare.com/markdownify/node/89&title=Image%20Protection%20with%20jQuery "Share to Facebook") [    ](https://www.linkedin.com/sharing/share-offsite/?url=https://www.skvare.com/markdownify/node/89 "Share to Linkedin") [    ](mailto:?subject=Image%20Protection%20with%20jQuery&body=https://www.skvare.com/markdownify/node/89 "Share to Email") 

 

 

#  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.