Easier than a flashmovie but less safe would be using a transparent image.
Now create a simple
snippet:
<?php
//set default base64 transparent image
if(!isset($imgTr)) {
$imgTr='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCB1jYAAAAAIAAc/INeUAAAAASUVORK5CYII=';
}
//make image path unreadable
function obfuscate($input, $par) {
$output=$input;
if($par) {
$output='';
for($i=0;$i<strlen($input);++$i) {
$n=rand(0, 1);
if($n) {
$output.=chr(38).'#x'.sprintf("%X", ord($input {$i})).';';
} else {
$output.=chr(38).'#'.ord($input {$i}).';';
}
}
}
return $output;
}
if(isset($imgPath)and!isset($obfusc)) {
$output='<img src="'.$imgTr.'" style="background: url('.$imgPath.') no-repeat 0 0; width:'.$imgWidth.'px; height:'.$imgHeight.'px;"/>';
} elseif(isset($id)) {
$output='<img id="'.$id.'" src="'.$imgTr.'" style="width:'.$imgWidth.'px; height:'.$imgHeight.'px;"/>';
} elseif(isset($obfusc)) {
$output='<img src="'.$imgTr.'" style="background: url('.obfuscate($imgPath, $obfusc).') no-repeat 0 0; width:'.$imgWidth.'px; height:'.$imgHeight.'px;"/>';
} else {
$output='';
}
return $output;
call it in your resource like this:
[[hiddenImage? &imgPath=`assets/images/test.png`
&obfusc=`1`
&imgWidth=`230`
&imgHeight=`80`
&imgTr=`assets/images/transparent.png`
]]
or if you set the background image in css.
#myimage{
background: url(assets/images/test.png) no-repeat 0 0;
}
[[hiddenImage?
&id=`myimage`
&imgTr=`assets/images/transparent.png`
&imgWidth=`230`
&imgHeight=`80`
]]
Now when the user tries to right click and download the image he/she will download a transparent image. Inspecting the source will show either an id or a obfuscated path to an image.
<img id="myimage" src="assets/images/transparent.png" style="width:230px; height:80px;"/>
or
<img src="assets/images/transparent.png" style="background: url(assets/images/test.png) no-repeat 0 0; width:230px; height:80px;"/>
or if no transparent image is set:
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCB1jYAAAAAIAAc/INeUAAAAASUVORK5CYII=" style="background: url(assets/images/test.png) no-repeat 0 0; width:230px; height:80px;"/>
This of course won’t stop a clever user but will most certainly discourage John Doe.