Page 1 of 1

to prevent right-click downloading

Posted: Thu Jun 02, 2022 5:50 pm
by jeronath
Hello everybody,

I have a basic question but I don't find the answer by myself as I am not a php developer.

I would like to add <body oncontextmenu="return false"> in my web site to prevent right-click downloading. In which php file and where in it can I add this ?

Thanks in advance for your help.

Re: to prevent right-click downloading

Posted: Thu Jun 02, 2022 11:50 pm
by Edi
Sorry, this question is not related to Bludit, and it is a misunderstanding.
I would like to add <body oncontextmenu="return false"> in my web site to prevent right-click downloading.
This has nothing to do with right clicks to disable downloading images.

oncontextmenu is a Javascript event that needs a function:

https://www.w3schools.com/jsref/event_oncontextmenu.asp

For disabling right clicks search for "disable right click images" or something like this. There are a lot of instructions how it can be done.

But be aware that images always can be downloaded despite disabling right clicks.

Re: to prevent right-click downloading

Posted: Sun Jun 05, 2022 2:48 pm
by multicolordev
I can create plugin for disable right button on all website on only or image if you want:)

Re: to prevent right-click downloading

Posted: Sun Jun 05, 2022 6:32 pm
by jeronath
multicolordev wrote: Sun Jun 05, 2022 2:48 pm I can create plugin for disable right button on all website on only or image if you want:)
Hello multicolordev,
I would like to know how to make a plugin but I am not a developer. So if you can make one to avoid the right-click either on some photos or on the whole site that would be really nice!
I use for my website royalty free photos but also sometimes personal photos a little worked and I would like to avoid that they are easy to download. Even if I know that by looking at the code you can find the url...
Thanks in advance!
Best regards.

Re: to prevent right-click downloading

Posted: Sun Jun 05, 2022 7:02 pm
by Edi
jeronath wrote: Sun Jun 05, 2022 6:32 pm I use for my website royalty free photos but also sometimes personal photos a little worked and I would like to avoid that they are easy to download. Even if I know that by looking at the code you can find the url...
Why looking at the code? A screenshoot is enough. ;-)

Or you can use a browser addon like this one:

https://chrome.google.com/webstore/deta ... ck-for-go/

People know what to do!

If you do not want that something can be downloaded from your website, do not upload it.

Re: to prevent right-click downloading

Posted: Mon Jun 06, 2022 4:16 pm
by jeronath
Edi wrote: Sun Jun 05, 2022 7:02 pm
jeronath wrote: Sun Jun 05, 2022 6:32 pm I use for my website royalty free photos but also sometimes personal photos a little worked and I would like to avoid that they are easy to download. Even if I know that by looking at the code you can find the url...
Why looking at the code? A screenshoot is enough. ;-)

Or you can use a browser addon like this one:

https://chrome.google.com/webstore/deta ... ck-for-go/

People know what to do!

If you do not want that something can be downloaded from your website, do not upload it.
Ok Edi there are many ways to download an image from a web page and I know I can't totally prevent it unless I am a very advanced developer which I am not. You wrote this to me in your two posts and I knew it even before your indications.
However, not everyone knows these ways or will look for them and it may be enough to disable the right click to prevent a number of these downloads.
But as I don't quite understand how a Bludit page is generated and I can't find the information in the documentation I repeat my question: in which file should I add code to prevent right-click on my site?
I found some code here: https://www.oflox.com/blog/how-to-disab ... ite_In_PHP but I don't know where to add it.
Is it possible to have an answer to this question?
Thank you in advance for your help.

Re: to prevent right-click downloading

Posted: Mon Jun 06, 2022 4:43 pm
by Edi
1) Open the file index.php of your theme, and add oncontextmenu="return false" to the tag <body>:

Code: Select all

<body oncontextmenu="return false">
2) Enable the plugin HTML Code and add the following to the field "Head":

Code: Select all

<script>
   window.oncontextmenu = function () {
      return false;
   }
   $(document).keydown(function (event) {
      if (event.keyCode == 123) {
         return false;
      }
      else if ((event.ctrlKey && event.shiftKey && event.keyCode == 73) || (event.ctrlKey && event.shiftKey && event.keyCode == 74)) {
         return false;
      }
   });
</script>

Re: to prevent right-click downloading

Posted: Mon Jun 06, 2022 6:39 pm
by jeronath
Edi wrote: Mon Jun 06, 2022 4:43 pm 1) Open the file index.php of your theme, and add oncontextmenu="return false" to the tag <body>:

Code: Select all

<body oncontextmenu="return false">
2) Enable the plugin HTML Code and add the following to the field "Head":

Code: Select all

<script>
   window.oncontextmenu = function () {
      return false;
   }
   $(document).keydown(function (event) {
      if (event.keyCode == 123) {
         return false;
      }
      else if ((event.ctrlKey && event.shiftKey && event.keyCode == 73) || (event.ctrlKey && event.shiftKey && event.keyCode == 74)) {
         return false;
      }
   });
</script>
Hello Edi,

Thanks a lot for your help !
That works perfectly !