yireo / Yireo_NextGenImages

45 stars 28 forks source link

The images on the catalog list page are not generated in the picture tag. #69

Closed hgati closed 1 year ago

hgati commented 1 year ago

catalog listing page

here are the img tags on the list page:

<img class="product-image-photo product-first-image-photo owl-lazy" src="https://localhost/static/version1694777003/frontend/Olegnax/athlete2_child/en_US/Olegnax_Core/images/preloader-img.svg" data-src="https://d3dtmxxxxx4g.cloudfront.net/catalog/product/cache/0b92992ca6366f8cb05593cfbb60c917/s/e/seventeen-going-magazine-vol-rn-0.jpg" width="489" height="489" alt="Seventeen Going Magazine Vol 2 #0"/>

<img class="product-image-photo product-second-image-photo owl-lazy" src="https://localhost/static/version1694777003/frontend/Olegnax/athlete2_child/en_US/Olegnax_Core/images/preloader-img.svg" data-src="https://d3dtmxxxxx4g.cloudfront.net/catalog/product/cache/0b92992ca6366f8cb05593cfbb60c917/s/e/seventeen-going-magazine-vol-1.jpg" width="489" height="489" alt="SEVENTEEN - GOING Magazine Vol. 2"/>

The actual product images in the image tags are located within the data-src attribute, not the src attribute. However, in the code below, it checks the src attribute and immediately breaks out of the loop, This leads to the picture tag not being generated for all the products on the list page.

https://github.com/yireo/Yireo_NextGenImages/blob/c1f26f7f9fcc0cb949fa55a18a730ad5caf97b0a/Util/HtmlReplacer.php#L300

As a result, fails to collect the actual images from the data-src attribute, and it falls into the subsequent code, leading to an immediate return. Therefore, no picture tags are generated for any of the images on the list page.

https://github.com/yireo/Yireo_NextGenImages/blob/c1f26f7f9fcc0cb949fa55a18a730ad5caf97b0a/Util/HtmlReplacer.php#L135