Disable right click on images

The onPageChange event should help you:

It’s executed whenever the user navigates in Discourse. $(document).ready isn’t enough because Discourse normally avoids full page reloads.

Something like this could work for you:

<script type="text/discourse-plugin" version="0.8">
  api.onPageChange((url, title) => {
    $("img").bind("contextmenu",function(e) {
      return false;
    });
  });
</script>

This doesn’t handle posts that are inserted into the page by infinite scrolling, but maybe it’s enough to appease your users :slight_smile:

(I understand this is a #marketplace post and you are looking for a fully baked solution. This isn’t that, but I thought it might still help.)

3 Likes