Reputation: 1369
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
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
Reputation: 7273
You can embed your images by converting them to base 64 format directly in your css/html...
Upvotes: 1
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