I have a custom Magento 2 Invoice PDF template. I manage to get all of the order/invoice info including the product image url but as soon as this is included in the img tag it is not displayed.
Retrieve the product thumb url:
$_objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $imageHelper = $_objectManager->get('\Magento\Catalog\Helper\Image'); $image_url = $imageHelper->init($product, 'product_thumbnail_image')->setImageFile($product->getFile())->resize(40, 40)->getUrl();
<img src="<?php echo $image_url; ?>" width="40" height="40" />
However, if I simply echo the thubmnail url without the img tag, the url is correct:
<?php echo $image_url; ?>
Why does this url not display when it is placed within an img tag?