0

Is there any way to rename the

data:image/webp;base64,base64_encode($thumbnail)

to

$IndPackProductImagesArray[0]

so that when someone right clicks to open in a new tab, there's a name instead of encoded text

Below is the code:

<?php
$image = new Imagick();
$image->readImage("images/industrial_packaging/".$IndPackProductImageDirName2."/".$IndPackProductImagesArray[0]);

$watermark = new Imagick();
$watermark->readImage("images/default_products_image_fg.webp");


$image->compositeImage($watermark, Imagick::COMPOSITE_DEFAULT, 0, 0);
$image->thumbnailImage(500, 500, true, true); 

header("Content-Type: image/" . $image->getImageFormat());

ob_start();
$thumbnail = $image->getImageBlob();
ob_get_contents();
ob_end_clean();
echo 
"
<img 
class=\"card-img-top\" 
src=\"data:image/webp;base64,".base64_encode($thumbnail)."\" 
style=\"background-image: url('images/default_products_image_bg.webp'); background-size:cover;\"
/>
";
?>  

Any help appreciated!

2
  • If this is something you are doing again and again, maybe is worth it to cache the image and provide an actual file with a filename.
    – msg
    Commented Apr 25, 2020 at 2:10
  • You're probably right with that but I uh, am not that expert yet... I'm just making things as I go. I'll do alternatives later when I'm more familiar with caches & cookie making...
    – Manny
    Commented Apr 26, 2020 at 12:26

0

Browse other questions tagged or ask your own question.