Fix code after code review

This commit is contained in:
Norbert Glanc 2025-09-26 09:54:11 +02:00
parent 7503f33b89
commit 6b47bc2252
2 changed files with 10 additions and 5 deletions

View file

@ -87,11 +87,16 @@ $.fn.extend({
const handleClickMainImage = function handleClickMainImage(e) {
e.preventDefault();
const mainImageSrcExploded = e.target.src.split('/');
const thumbnails = $('[data-lightbox="sylius-product-image"]');
if (thumbnails.length > 0) {
thumbnails[0].click();
}
thumbnails.each((index, element) => {
const imageSrcExploded = $(element).find('img').attr('src').split('/');
if (mainImageSrcExploded[mainImageSrcExploded.length - 1] === imageSrcExploded[imageSrcExploded.length - 1]) {
element.click();
}
});
};
const mainImage = $('#main-image');
const mainImage = $('a.ui.fluid.image > img');
mainImage.click(handleClickMainImage);

View file

@ -16,7 +16,7 @@
{% endif %}
<div data-product-image="{{ path }}" data-product-link="{{ original_path }}"></div>
<a href="{{ original_path }}" class="ui fluid image">
<a href="{{ original_path }}" class="ui fluid image"{% if product.images|length < 2%} data-lightbox="sylius-product-image"{% endif %}>
<img src="{{ path }}" id="main-image" alt="{{ product.name }}" {{ sylius_test_html_attribute('main-image') }} />
</a>
{% if product.images|length > 1 %}