# Desativar o clique direito em imagens

**URL:** https://meta.discourse.org/t/disable-right-click-on-images/96362
**Category:** Marketplace
**Created:** [4 Setembro , 2018 23:37 UTC](https://meta.discourse.org/t/disable-right-click-on-images/96362 "2018-09-04T23:37:38Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![davidkingham](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/davidkingham/32/119528_2.png) [@davidkingham](https://meta.discourse.org/u/davidkingham)
#### Post date: [4 Setembro , 2018 23:37 UTC](https://meta.discourse.org/t/disable-right-click-on-images/96362/1 "2018-09-04T23:37:38Z")

</div>

What would you like done?  
I know this is ridiculous but my users are photographers and many of them are older folks and don’t understand how easy this is to bypass, so just go with me here.

I do not want to turn off pointer events because I still want the users to be able to zoom in to the full size image, and I don’t want to disable right click globally and reduce functionality.

I have tried this script for the thumbnail which only works when you refresh the page

```
<script type="text/javascript">
    $(document).ready(function(){
      $("img").bind("contextmenu",function(e){
        return false;
      });
    });
  </script>

```

Any creative ideas on how to get this working without losing functionality?

When do you need it done?  
ASAP

What is your budget, in $ USD that you can offer for this task?  
$100

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [5 Setembro , 2018 19:03 UTC](https://meta.discourse.org/t/disable-right-click-on-images/96362/2 "2018-09-05T19:03:54Z")

</div>

The `onPageChange` event should help you:

> [@Developing Discourse Themes & Theme Components](https://meta.discourse.org/t/developer-s-guide-to-discourse-themes/93648#heading--4-c-11):
>
> Discourse Themes and Theme Components can be used to customize the look, feel and functionality of Discourse’s frontend. This section of the developer guides aims to provide all the reference materials you need to develop simple themes for a single site, right up to complex open-source theme components. This introduction aims to provide a map of all the tools and APIs for theme development. If you prefer a step-by-step tutorial for theme development, jump straight to: Themes vs. Theme Compon…

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:

```javascript
<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 🙂

(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.)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [6 Setembro , 2018 00:35 UTC](https://meta.discourse.org/t/disable-right-click-on-images/96362/3 "2018-09-06T00:35:33Z")

</div>

I think this was already answered elsewhere?

---

<div class="post-metadata">

### Author: ![davidkingham](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/davidkingham/32/119528_2.png) [@davidkingham](https://meta.discourse.org/u/davidkingham)
#### Post date: [6 Setembro , 2018 00:48 UTC](https://meta.discourse.org/t/disable-right-click-on-images/96362/4 "2018-09-06T00:48:07Z")

</div>

> [@codinghorror](#):
>
> I think this was already answered elsewhere?

Yes, I’m not sure where the replies went, but I do not need this anymore.

Thank you @fefrei for chiming in.

This what I ultimately went with

```
<script type="text/discourse-plugin" version="0.8">

const TopicRoute = require("discourse/routes/topic").default;

TopicRoute.reopen({
	activate: function() {
		this._super();
		Em.run.next(function() {
		    $('body').on('contextmenu', '.cooked img, .mfp-img', function(e){ return false; });
		});
	}
});
</script>

```

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [6 Outubro , 2018 00:54 UTC](https://meta.discourse.org/t/disable-right-click-on-images/96362/5 "2018-10-06T00:54:28Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
