diff --git a/composer.json b/composer.json index d0003b0..51b1faa 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "thumbnail" ], "description": "Automatically calculate the best thumbnail size. This means you don't have to worry about the \"sizes\" attribute for the images. Additionally, you gain a score.", - "version": "1.1.1", + "version": "1.1.2", "type": "shopware-platform-plugin", "license": "mit", "authors": [ @@ -16,7 +16,7 @@ } ], "require": { - "shopware/core": "~6.4.10" + "shopware/core": "~6.4.18" }, "extra": { "shopware-plugin-class": "Frosh\\LazySizes\\FroshLazySizes", diff --git a/src/Resources/views/storefront/utilities/thumbnail.html.twig b/src/Resources/views/storefront/utilities/thumbnail.html.twig index d995061..49527bb 100644 --- a/src/Resources/views/storefront/utilities/thumbnail.html.twig +++ b/src/Resources/views/storefront/utilities/thumbnail.html.twig @@ -1,3 +1,28 @@ -{% apply spaceless %} - {% sw_include '@FroshLazySizes/storefront/utilities/thumbnail-lazysize.html.twig' %} -{% endapply %} +{% sw_extends "@Storefront/storefront/utilities/thumbnail.html.twig" %} + +{% block thumbnail_utility %}{% apply spaceless %} + {% if lazysizes is not defined %} + {% set lazysizesThroughCss = null %} + {% for item in [sectionClasses, blockClasses] %} + {% if item is defined %} + {# Yes, item is an array! + Therefore we need to combine any entry and convert it back to array #} + {% set item = item|join(' ')|split(' ') %} + + {% if 'no-lazysizes' in item %} + {% set lazysizesThroughCss = false %} + {% elseif 'lazysizes' in item %} + {% set lazysizesThroughCss = true %} + {% endif %} + {% endif %} + {% endfor %} + {% endif %} + + {% set lazysizes = lazysizes ?? lazysizesThroughCss ?? true %} + + {% if lazysizes %} + {% sw_include '@FroshLazySizes/storefront/utilities/thumbnail-lazysize.html.twig' %} + {% else %} + {{ parent() }} + {% endif %} +{% endapply%}{% endblock %} \ No newline at end of file