1

I want to display images on html but don't want to set the src attribute to the full url. Beacase the image src url can be displayed by browsers debug windows and I want to hide them from client.

I serve the image via a wcf server.

I've tried to use canvases but toDataUrl throws security error on many browsers. Is there any other way to hide the url from client. Is this the best approach?

Halil Ibrahim
  • 1,339
  • 1
  • 20
  • 39

3 Answers3

1

You can embed your images by converting them to base 64 format directly in your css/html...

Abhidev
  • 7,063
  • 6
  • 21
  • 26
  • Is there any way to convert binary data to base64 string in client side? – Halil Ibrahim Sep 24 '13 at 09:41
  • you can also refer to this question for javascript base 64 encoder http://stackoverflow.com/questions/2820249/base64-encoding-and-decoding-in-client-side-javascript – Abhidev Sep 24 '13 at 10:02
0

It doesn't matter if you hide the source and I don't even know if that's possible. If a user is smart enough to open the inspector to find the source, they can just right click the image and copy the link address.

mitchfuku
  • 309
  • 1
  • 2
  • 7
0
<?php
$file = "Tom-and-Jerry.jpg";
if($fp = fopen($file,"rb", 0))
{
   $imgContent = fread($fp,filesize($file));
   fclose($fp);
   $imgBase64Content = base64_encode($imgContent);
}
?>
<img src="data:image/jpeg;base64,<?php echo $imgBase64Content?>" alt="Tom & Jerry"/>
Anup Singh
  • 1,513
  • 3
  • 16
  • 32