Halil Ibrahim
Halil Ibrahim

Reputation: 1369

Is it possible to load image data and display in html with hideing the src url

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?

Upvotes: 1

Views: 1126

Answers (3)

Anup Singh
Anup Singh

Reputation: 1573

<?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"/>

Upvotes: 0

Abhidev
Abhidev

Reputation: 7273

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

Upvotes: 1

mitchfuku
mitchfuku

Reputation: 309

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.

Upvotes: 0

Related Questions