Calling admin Panel product placeholder image to frontend.

Here we can take the object manager to get the backend placeholder url of the image.

It can be done with block or $objectmanager within the phtml file.

For getting the Repositories we need to add some code to pull it to our phtml file.

$imageHelper = \Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\Catalog\Helper\Image::class);

For calling $imageHelper Lib

for all repositories we can use like:-

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();

$_assetRepo = $objectManager->create('Magento\Framework\View\Asset\Repository');
//assetRepo

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
 $helperImageFactory = $objectManager->create('\Magento\Catalog\Helper\ImageFactory');
//ImageFactory

Using :- $imageHelper = \Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\Catalog\Helper\Image::class);

this code we get the back end catalog placeholder image to front end side:–

also add the code to get the image Url

echo $imageHelper->getDefaultPlaceholderUrl('image');
for img use img src tag to display the image

Leave a comment

Your email address will not be published. Required fields are marked *