Disable right click on images

Question:

I am wondering if there is a way to disable right click so users can't view or download individual images?

Answer:

You can disable right click on images with JavaScript but it won't prevent people from downloading them.

In fact, there is no way to stop people downloading the images. As long as the image is public on your webpage, no matter what you do, there will be a way to download it. I think the only way to protect them is adding some watermarks to the images.

Anyway, to disable right click, you can add the following JavaScript to your webpage. The script will disable right clicks on images.

<script>
(function($){
  $(document).on('contextmenu', 'img', function() {
      return false;
  })
})(jQuery);
</script>