Magento – Avoid loading product image from cache in magento 2

imagemagento2product-images

I have issue in product images.

Right now products are loading from cache from the path like below.

  site_url/media/catalog/product/cache/2765542505660baab28ecd555e27366e/t/m/image_name.jpg

This is leading to 404 error page.

But if we remove cache from the image url, the image is loading successfully.

like below one

 site_url/media/catalog/product/t/m/image_name.jpg

This will load the image correctly,

So I am planning to change the image url like this in all the pages.

How can load the image without cache path in product list page and in detail pages.

Can anyone look into this and update me ideas.

Thanks in advance!!

Best Answer

you shoud have product collection.

// return array, you can choose what you want
$image = $product->getMediaGalleryImages();