How do i prevent downloading of pictures on a page
Asked by Mark Nixon:

Hi,

I wish to add a photo/picture/diagram/whatever to a confluence page, however I wish to protect it to stop people from right clicking and saving the photo. I know there are ways around this, however we just need a simple solution to help prevent distribution of out-of-date photos and diagrams.

I have seen it done on websites in the past - can it be done in Confluence??

Thanks

Mark


Answers:
author: Jim Birch
body: There's no perfect method. If you can see it, your browser has already downloaded it, so it's somewherre in the cache or accessible via the image url. A smart user can find it. All you can do is foul up the R-Click/SaveAs. It's almost alway possible to create a screenshot, except with very elaborate stuff like converting the image to a Flash effect.

1. Disable right click with javascript, or pop up a message saying "please don't download content will be updated. This will annoy users who use r-click for other things.

2. Create a macro that displays the image with a 100% transparent overlay. I think you'll need to include pixel size in the macro, which is messy. R-Click/Save will save the overlay not the image. However, the user can still search their cache or take a screenshot to get the pick. You could muck around with transparency and mouseover something to degrade the screenshot or swap the image on r-click. It's still in cache.

3. Place a caption "Please don't download, use a link for the latest version under the pic. People will be able to download but may not.

4. Watermark image with link to the latest version.

5. Chop up the image into pieces and tile them. May need a macro and parameters to handle this. Most people will get annoyed and give up. You may get sick of slicing up images

6. Some complicated kind of flash eg popup construct could stop screenshots.

7. Forget it. Get over it.


author: MatthewC
body: You could put some javascript on every page to disable the right click. It's not fool proof as it's easily by-passed by disabling Javascript but it might make a point.

Go to Confluence admin \> Custom HTML \& paste the code below into the **HEAD** section.

If you get an error, just check that the browser hasn't decided to swap the quotes (") and the extended quotes characters (" ")
> \<script language=JavaScript\>
>
> var message="Please do not download the images.";
>
> function clickIE6(){
>
> if (event.button==2){
>
> alert(message);
>
> return false;
>
> }
>
> }
>
> function clickNS4(e){
>
> if (document.layers\|\|document.getElementById\&\&!document.all){
>
> if (e.which==2\|\|e.which==3){
>
> alert(message);
>
> return false;
>
> }
>
> }
>
> }
>
> if (document.layers){
>
> document.captureEvents(Event.MOUSEDOWN);
>
> document.onmousedown=clickNS4;
>
> }
>
> else if (document.all\&\&!document.getElementById){
>
> document.onmousedown=clickIE6;
>
> }
>
> document.oncontextmenu=new Function("alert(message);return false")
>
> \</script\>
>
You could also stop hot-linking images if you put confluence behind an Apache instance \& used re-write rules based on the referer field... but that's another question!


author: Mark Nixon
body: Thanks guys for your comments. While you are right and its easy to bypass, its just to stop the 99% of average users quickly saving it and forwarding pictures/images to clients that should not be forwarded.


author: imacutegirl26
body: You could put some javascript on every page to disable the right click. It's not fool proof as it's easily by-passed by disabling Javascript but it might make a point.

Go to Confluence admin \> Custom HTML \& paste the code below into the **HEAD** section.

If you get an error, just check that the browser hasn't decided to swap the quotes (") and the extended quotes characters (" ")
> \<script language=JavaScript\>
>
> var message="Please do not download the images.";
>
> function clickIE6(){
>
> if (event.button==2){
>
> alert(message);
>
> return false;
>
> }
>
> }
>
> function clickNS4(e){
>
> if (document.layers\|\|document.getElementById\&\&!document.all){
>
> if (e.which==2\|\|e.which==3){
>
> alert(message);
>
> return false;
>
> }
>
> }
>
> }
>
> if (document.layers){
>
> document.captureEvents(Event.MOUSEDOWN);
>
> document.onmousedown=clickNS4;
>
> }
>
> else if (document.all\&\&!document.getElementById){
>
> document.onmousedown=clickIE6;
>
> }
>
> document.oncontextmenu=new Function("alert(message);return false")
>
> \</script\>
>
> \[spam links removed\]


Tags: image

security