The product image URL of a Magento 2 store is like:


I would like to remove the “cache/8b8f1e61e783e783c045142bcb34d1e0b2a9/” from the URL, because I have a lot of 404 error in logs due to that.

As you know, each time the cache is cleaned and regenerated, the URL hash change and the search engines does not find the previews one.

Has anyone ever had this kind of situation before? Thanks in advance for your help

1 Answer 1


Please try this.

$store = $objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore();
$imageUrl = $store->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . 'catalog/product' . $product->getImage();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.