From 6af7c7a9961749257d8852ab0abeca3697e051c7 Mon Sep 17 00:00:00 2001 From: tinect Date: Tue, 27 Oct 2020 17:01:57 +0100 Subject: [PATCH] Add option to specify max size of container --- CHANGELOG_de-DE.md | 4 ++++ CHANGELOG_en-GB.md | 4 ++++ composer.json | 2 +- .../js/frosh-platform-thumbnail-processor.js | 2 +- src/Resources/config/config.xml | 13 +++++++++++-- .../js/frosh-platform-thumbnail-processor.js | 2 +- .../views/storefront/utilities/thumbnail.html.twig | 7 ++++++- 7 files changed, 28 insertions(+), 6 deletions(-) diff --git a/CHANGELOG_de-DE.md b/CHANGELOG_de-DE.md index 1ffd29f..f8ff8a4 100644 --- a/CHANGELOG_de-DE.md +++ b/CHANGELOG_de-DE.md @@ -1,3 +1,7 @@ +# 1.0.13 + +* FEATURE Option hinzugefügt, um die maximale Containergröße zu definieren + # 1.0.12 * BUGFIX Behebe Problem beim Ersetzen von Medien diff --git a/CHANGELOG_en-GB.md b/CHANGELOG_en-GB.md index eebd16d..f0eb289 100644 --- a/CHANGELOG_en-GB.md +++ b/CHANGELOG_en-GB.md @@ -1,3 +1,7 @@ +# 1.0.13 + +* FEATURE Added Option to set max width of container + # 1.0.12 * BUGFIX Fix error when replacing media diff --git a/composer.json b/composer.json index a337742..a7760b4 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "thumbnail" ], "description": "This plugins allows you to use variable thumbnails, without having them on storage.", - "version": "1.0.12", + "version": "1.0.13", "type": "shopware-platform-plugin", "license": "mit", "authors": [ diff --git a/src/Resources/app/storefront/dist/storefront/js/frosh-platform-thumbnail-processor.js b/src/Resources/app/storefront/dist/storefront/js/frosh-platform-thumbnail-processor.js index d62407f..c27830c 100644 --- a/src/Resources/app/storefront/dist/storefront/js/frosh-platform-thumbnail-processor.js +++ b/src/Resources/app/storefront/dist/storefront/js/frosh-platform-thumbnail-processor.js @@ -1 +1 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([["frosh-platform-thumbnail-processor"],{"/C/M":function(t,e,i){var n,a,r;!function(o,s){if(o){s=s.bind(null,o,o.document),t.exports?s(i("gyLt")):(a=[i("gyLt")],void 0===(r="function"==typeof(n=s)?n.apply(e,a):n)||(t.exports=r))}}("undefined"!=typeof window?window:0,(function(t,e,i){"use strict";var n=function(){var a,r,o,s,l,d,c,u=i.cfg,f={"data-bgset":1,"data-include":1,"data-poster":1,"data-bg":1,"data-script":1},v="(\\s|^)("+u.loadedClass,g=e.documentElement,p=function(t){i.rAF((function(){i.rC(t,u.loadedClass),u.unloadedClass&&i.rC(t,u.unloadedClass),i.aC(t,u.lazyClass),("none"==t.style.display||t.parentNode&&"none"==t.parentNode.style.display)&&setTimeout((function(){i.loader.unveil(t)}),0)}))},y=function(t){var e,i,n,a;for(e=0,i=t.length;e0)&&"visible"!=z(a,"overflow")&&(n=a.getBoundingClientRect(),o=H>n.left&&In.top-1&&D500&&r.clientWidth>500?500:370:a.expand,n._defEx=v,g=v*a.expFactor,p=a.hFac,$=null,Q2&&B>2&&!e.hidden?(Q=g,X=0):Q=B>1&&X>1&&V<6?v:0),f!==d&&(O=innerWidth+d*p,R=innerHeight+d,c=-1*d,f=d),o=y[i].getBoundingClientRect(),(U=o.bottom)>=c&&(D=o.top)<=R&&(H=o.right)>=c*p&&(I=o.left)<=O&&(U||H||I||D)&&(a.loadHidden||Y(y[i]))&&(T&&V<3&&!u&&(B<3||X<4)||Z(y[i],d))){if(st(y[i]),l=!0,V>9)break}else!l&&T&&!s&&V<4&&X<4&&B>2&&(P[0]||a.preloadAfterLoad)&&(P[0]||!u&&(U||H||I||D||"auto"!=y[i].getAttribute(a.sizesAttr)))&&(s=P[0]||y[i]);s&&!l&&st(s)}},et=function(t){var e,n=0,r=a.throttleDelay,o=a.ricTimeout,s=function(){e=!1,n=i.now(),t()},d=c&&o>49?function(){c(s,{timeout:o}),o!==a.ricTimeout&&(o=a.ricTimeout)}:L((function(){l(s)}),!0);return function(t){var a;(t=!0===t)&&(o=33),e||(e=!0,(a=r-(i.now()-n))<0&&(a=0),t||a<9?d():l(d,a))}}(tt),it=function(t){var e=t.target;e._lazyCache?delete e._lazyCache:(K(t),y(e,a.loadedClass),b(e,a.loadingClass),m(e,at),A(e,"lazyloaded"))},nt=L(it),at=function(t){nt({target:t.target})},rt=function(t){var e,i=t.getAttribute(a.srcsetAttr);(e=a.customMedia[t.getAttribute("data-media")||t.getAttribute("media")])&&t.setAttribute("media",e),i&&t.setAttribute("srcset",i)},ot=L((function(t,e,i,n,r){var o,s,d,c,f,v;(f=A(t,"lazybeforeunveil",e)).defaultPrevented||(n&&(i?y(t,a.autosizesClass):t.setAttribute("sizes",n)),s=t.getAttribute(a.srcsetAttr),o=t.getAttribute(a.srcAttr),r&&(c=(d=t.parentNode)&&u.test(d.nodeName||"")),v=e.firesLoad||"src"in t&&(s||o||c),f={target:t},y(t,a.loadingClass),v&&(clearTimeout(k),k=l(K,2500),m(t,at,!0)),c&&g.call(d.getElementsByTagName("source"),rt),s?t.setAttribute("srcset",s):o&&!c&&(J.test(t.nodeName)?function(t,e){try{t.contentWindow.location.replace(e)}catch(i){t.src=e}}(t,o):t.src=o),r&&(s||c)&&h(t,{src:o})),t._lazyRace&&delete t._lazyRace,b(t,a.lazyClass),E((function(){var e=t.complete&&t.naturalWidth>1;v&&!e||(e&&y(t,"ls-is-cached"),it(f),t._lazyCache=!0,l((function(){"_lazyCache"in t&&delete t._lazyCache}),9)),"lazy"==t.loading&&V--}),!0)})),st=function(t){if(!t._lazyRace){var e,i=q.test(t.nodeName),n=i&&(t.getAttribute(a.sizesAttr)||t.getAttribute("sizes")),r="auto"==n;(!r&&T||!i||!t.getAttribute("src")&&!t.srcset||t.complete||p(t,a.errorClass)||!p(t,a.lazyClass))&&(e=A(t,"lazyunveilread").detail,r&&_.updateElem(t,!0,t.offsetWidth),t._lazyRace=!0,V++,ot(t,e,r,n,i))}},lt=w((function(){a.loadMode=3,et()})),dt=function(){3==a.loadMode&&(a.loadMode=2),lt()},ct=function(){T||(i.now()-W<999?l(ct,999):(T=!0,a.loadMode=3,et(),s("scroll",dt,!0)))},{_:function(){W=i.now(),n.elements=e.getElementsByClassName(a.lazyClass),P=e.getElementsByClassName(a.lazyClass+" "+a.preloadClass),s("scroll",et,!0),s("resize",et,!0),s("pageshow",(function(t){if(t.persisted){var i=e.querySelectorAll("."+a.loadingClass);i.length&&i.forEach&&d((function(){i.forEach((function(t){t.complete&&st(t)}))}))}})),t.MutationObserver?new MutationObserver(et).observe(r,{childList:!0,subtree:!0,attributes:!0}):(r.addEventListener("DOMNodeInserted",et,!0),r.addEventListener("DOMAttrModified",et,!0),setInterval(et,999)),s("hashchange",et,!0),["focus","mouseover","click","load","transitionend","animationend"].forEach((function(t){e.addEventListener(t,et,!0)})),/d$|^c/.test(e.readyState)?ct():(s("load",ct),e.addEventListener("DOMContentLoaded",et),l(ct,2e4)),n.elements.length?(tt(),E._lsFlush()):et()},checkElems:et,unveil:st,_aLSL:dt}),_=(S=L((function(t,e,i,n){var a,r,o;if(t._lazysizesWidth=n,n+="px",t.setAttribute("sizes",n),u.test(e.nodeName||""))for(r=0,o=(a=e.getElementsByTagName("source")).length;rn)&&(a=e*(n/i)),a):e}};i.parentFit=d,e.addEventListener("lazybeforesizes",(function(t){if(!t.defaultPrevented&&t.detail.instance==i){var e=t.target;t.detail.width=d.calculateSize(e,t.detail.width)}}))}}))}).call(this,i("UoTJ"))}},[["jrnS","runtime","vendor-node","vendor-shared"]]]); \ No newline at end of file +(window.webpackJsonp=window.webpackJsonp||[]).push([["frosh-platform-thumbnail-processor"],{"/C/M":function(t,e,i){var n,a,r;!function(o,s){if(o){s=s.bind(null,o,o.document),t.exports?s(i("gyLt")):(a=[i("gyLt")],void 0===(r="function"==typeof(n=s)?n.apply(e,a):n)||(t.exports=r))}}("undefined"!=typeof window?window:0,(function(t,e,i){"use strict";var n=function(){var a,r,o,s,l,d,c,u=i.cfg,f={"data-bgset":1,"data-include":1,"data-poster":1,"data-bg":1,"data-script":1},v="(\\s|^)("+u.loadedClass,g=e.documentElement,p=function(t){i.rAF((function(){i.rC(t,u.loadedClass),u.unloadedClass&&i.rC(t,u.unloadedClass),i.aC(t,u.lazyClass),("none"==t.style.display||t.parentNode&&"none"==t.parentNode.style.display)&&setTimeout((function(){i.loader.unveil(t)}),0)}))},y=function(t){var e,i,n,a;for(e=0,i=t.length;e0)&&"visible"!=z(a,"overflow")&&(n=a.getBoundingClientRect(),o=H>n.left&&In.top-1&&D500&&r.clientWidth>500?500:370:a.expand,n._defEx=v,g=v*a.expFactor,p=a.hFac,$=null,Q2&&B>2&&!e.hidden?(Q=g,X=0):Q=B>1&&X>1&&V<6?v:0),f!==d&&(O=innerWidth+d*p,R=innerHeight+d,c=-1*d,f=d),o=y[i].getBoundingClientRect(),(U=o.bottom)>=c&&(D=o.top)<=R&&(H=o.right)>=c*p&&(I=o.left)<=O&&(U||H||I||D)&&(a.loadHidden||Y(y[i]))&&(T&&V<3&&!u&&(B<3||X<4)||Z(y[i],d))){if(st(y[i]),l=!0,V>9)break}else!l&&T&&!s&&V<4&&X<4&&B>2&&(P[0]||a.preloadAfterLoad)&&(P[0]||!u&&(U||H||I||D||"auto"!=y[i].getAttribute(a.sizesAttr)))&&(s=P[0]||y[i]);s&&!l&&st(s)}},et=function(t){var e,n=0,r=a.throttleDelay,o=a.ricTimeout,s=function(){e=!1,n=i.now(),t()},d=c&&o>49?function(){c(s,{timeout:o}),o!==a.ricTimeout&&(o=a.ricTimeout)}:L((function(){l(s)}),!0);return function(t){var a;(t=!0===t)&&(o=33),e||(e=!0,(a=r-(i.now()-n))<0&&(a=0),t||a<9?d():l(d,a))}}(tt),it=function(t){var e=t.target;e._lazyCache?delete e._lazyCache:(K(t),y(e,a.loadedClass),b(e,a.loadingClass),m(e,at),A(e,"lazyloaded"))},nt=L(it),at=function(t){nt({target:t.target})},rt=function(t){var e,i=t.getAttribute(a.srcsetAttr);(e=a.customMedia[t.getAttribute("data-media")||t.getAttribute("media")])&&t.setAttribute("media",e),i&&t.setAttribute("srcset",i)},ot=L((function(t,e,i,n,r){var o,s,d,c,f,v;(f=A(t,"lazybeforeunveil",e)).defaultPrevented||(n&&(i?y(t,a.autosizesClass):t.setAttribute("sizes",n)),s=t.getAttribute(a.srcsetAttr),o=t.getAttribute(a.srcAttr),r&&(c=(d=t.parentNode)&&u.test(d.nodeName||"")),v=e.firesLoad||"src"in t&&(s||o||c),f={target:t},y(t,a.loadingClass),v&&(clearTimeout(k),k=l(K,2500),m(t,at,!0)),c&&g.call(d.getElementsByTagName("source"),rt),s?t.setAttribute("srcset",s):o&&!c&&(J.test(t.nodeName)?function(t,e){try{t.contentWindow.location.replace(e)}catch(i){t.src=e}}(t,o):t.src=o),r&&(s||c)&&h(t,{src:o})),t._lazyRace&&delete t._lazyRace,b(t,a.lazyClass),E((function(){var e=t.complete&&t.naturalWidth>1;v&&!e||(e&&y(t,"ls-is-cached"),it(f),t._lazyCache=!0,l((function(){"_lazyCache"in t&&delete t._lazyCache}),9)),"lazy"==t.loading&&V--}),!0)})),st=function(t){if(!t._lazyRace){var e,i=q.test(t.nodeName),n=i&&(t.getAttribute(a.sizesAttr)||t.getAttribute("sizes")),r="auto"==n;(!r&&T||!i||!t.getAttribute("src")&&!t.srcset||t.complete||p(t,a.errorClass)||!p(t,a.lazyClass))&&(e=A(t,"lazyunveilread").detail,r&&_.updateElem(t,!0,t.offsetWidth),t._lazyRace=!0,V++,ot(t,e,r,n,i))}},lt=w((function(){a.loadMode=3,et()})),dt=function(){3==a.loadMode&&(a.loadMode=2),lt()},ct=function(){T||(i.now()-W<999?l(ct,999):(T=!0,a.loadMode=3,et(),s("scroll",dt,!0)))},{_:function(){W=i.now(),n.elements=e.getElementsByClassName(a.lazyClass),P=e.getElementsByClassName(a.lazyClass+" "+a.preloadClass),s("scroll",et,!0),s("resize",et,!0),s("pageshow",(function(t){if(t.persisted){var i=e.querySelectorAll("."+a.loadingClass);i.length&&i.forEach&&d((function(){i.forEach((function(t){t.complete&&st(t)}))}))}})),t.MutationObserver?new MutationObserver(et).observe(r,{childList:!0,subtree:!0,attributes:!0}):(r.addEventListener("DOMNodeInserted",et,!0),r.addEventListener("DOMAttrModified",et,!0),setInterval(et,999)),s("hashchange",et,!0),["focus","mouseover","click","load","transitionend","animationend"].forEach((function(t){e.addEventListener(t,et,!0)})),/d$|^c/.test(e.readyState)?ct():(s("load",ct),e.addEventListener("DOMContentLoaded",et),l(ct,2e4)),n.elements.length?(tt(),E._lsFlush()):et()},checkElems:et,unveil:st,_aLSL:dt}),_=(S=L((function(t,e,i,n){var a,r,o;if(t._lazysizesWidth=n,n+="px",t.setAttribute("sizes",n),u.test(e.nodeName||""))for(r=0,o=(a=e.getElementsByTagName("source")).length;rn)&&(a=e*(n/i)),a):e}};i.parentFit=d,e.addEventListener("lazybeforesizes",(function(t){if(!t.defaultPrevented&&t.detail.instance==i){var e=t.target;t.detail.width=d.calculateSize(e,t.detail.width)}}))}}))}).call(this,i("UoTJ"))}},[["jrnS","runtime","vendor-node","vendor-shared"]]]); \ No newline at end of file diff --git a/src/Resources/config/config.xml b/src/Resources/config/config.xml index f886b28..16b20c2 100644 --- a/src/Resources/config/config.xml +++ b/src/Resources/config/config.xml @@ -38,7 +38,7 @@ 1 - There is some problem with thumbnail-sizes in storefront. + There are problems with thumbnail-sizes in storefront. This can help you delivering better matching sizes to the visitor. @@ -48,11 +48,20 @@ 1 - There is some problem with thumbnail-sizes in the gallery of the product page. + There are problems with thumbnail-sizes in the gallery of the product page. This can help you delivering better matching sizes to the visitor. + + DefaultContainerMaxSize + + 1360 + + There may be reasons you modified the container max size. So you can adjust this here for thumbnails. If you don't know, keep it at 1360. + + + froshthumbnailprocessorinfotexts diff --git a/src/Resources/public/administration/js/frosh-platform-thumbnail-processor.js b/src/Resources/public/administration/js/frosh-platform-thumbnail-processor.js index 0811e0a..a628e3f 100644 --- a/src/Resources/public/administration/js/frosh-platform-thumbnail-processor.js +++ b/src/Resources/public/administration/js/frosh-platform-thumbnail-processor.js @@ -1 +1 @@ -(this.webpackJsonp=this.webpackJsonp||[]).push([["frosh-platform-thumbnail-processor"],{"7wHn":function(e,t){e.exports='{% block frosh_thumbnail_processor_info_texts %}\n
\n

\n available variables:
\n {mediaUrl}: f.e. https://cdn.test.de/
\n {mediaPath}: f.e. media/image/5b/6d/16/tea.png
\n {width}: f.e. 800
\n {height}: f.e. 800\n

\n\n

Tested Supports

\n

Any service provider that changes image sizes using the url parameter should also be compatible.

\n\n

imgproxy (selfhosted)

\n

\n \n will become http://localhost:8080/x/fit/800/800/sm/0/plain/https://www.example.com/media/01/82/69/sasse.png\n

\n\n

BunnyCDN

\n
Opinion: not cheap with 9,5$/m per zone, but fast and including webp
\n

\n You would have to active "Bunny Optimizer" and "Manipulation Engine" in your Zone in BunnyCDN.

\n \n will become https://www.example.com/media/01/82/69/sasse.png?width=800&height=800\n

\n\n

Images.weserv.nl

\n
Opinion: free, but slow and without webp
\n

\n An image cache & resize service. Manipulate images on-the-fly with a worldwide cache.

\n \n will become\n https://images.weserv.nl/?url=https://www.example.com/media/01/82/69/sasse.png&w=800&h=800\n

\n\n

cloudimage

\n
Opinion: has free plan, fast and including webp
\n

\n An image cache & resize service. Manipulate images on-the-fly with a worldwide cache.

\n \n will become\n https://token.cloudimg.io/v7/https://www.example.com/media/01/82/69/sasse.png&w=800&h=800\n

\n
\n{% endblock %}\n'},"82rC":function(e,t,a){var n=a("c0+O");"string"==typeof n&&(n=[[e.i,n,""]]),n.locals&&(e.exports=n.locals);(0,a("SZ7m").default)("f192babe",n,!0,{})},RsLZ:function(e,t,a){"use strict";a.r(t);var n=a("7wHn"),s=a.n(n);a("82rC");Shopware.Component.register("frosh-thumbnail-processor-info-texts",{template:s.a})},"c0+O":function(e,t,a){}},[["RsLZ","runtime","vendors-node"]]]); \ No newline at end of file +(this.webpackJsonp=this.webpackJsonp||[]).push([["frosh-platform-thumbnail-processor"],{"7wHn":function(e,t){e.exports='{% block frosh_thumbnail_processor_info_texts %}\n
\n

\n available variables:
\n {mediaUrl}: f.e. https://cdn.test.de/
\n {mediaPath}: f.e. media/image/5b/6d/16/tea.png
\n {width}: f.e. 800
\n {height}: f.e. 800\n

\n\n

Tested Supports

\n

Any service provider that changes image sizes using the url parameter should also be compatible.

\n\n

imgproxy (selfhosted)

\n

\n \n will become http://localhost:8080/x/fit/800/800/sm/0/plain/https://www.example.com/media/01/82/69/sasse.png\n

\n\n

BunnyCDN

\n
Opinion: not cheap with 9,5$/m per zone, but fast and including webp
\n

\n You would have to active "Bunny Optimizer" and "Manipulation Engine" in your Zone in BunnyCDN.

\n \n will become https://www.example.com/media/01/82/69/sasse.png?width=800&height=800\n

\n\n

Images.weserv.nl

\n
Opinion: free, but slow and without webp
\n

\n An image cache & resize service. Manipulate images on-the-fly with a worldwide cache.

\n \n will become\n https://images.weserv.nl/?url=https://www.example.com/media/01/82/69/sasse.png&w=800&h=800\n

\n\n

cloudimage

\n
Opinion: has free plan, fast and including webp
\n

\n An image cache & resize service. Manipulate images on-the-fly with a worldwide cache.

\n \n will become\n https://token.cloudimg.io/v7/https://www.example.com/media/01/82/69/sasse.png&w=800&h=800\n

\n
\n{% endblock %}\n'},"82rC":function(e,t,a){var n=a("iRd4");"string"==typeof n&&(n=[[e.i,n,""]]),n.locals&&(e.exports=n.locals);(0,a("t/wU").default)("37af8a43",n,!0,{})},RsLZ:function(e,t,a){"use strict";a.r(t);var n=a("7wHn"),s=a.n(n);a("82rC");Shopware.Component.register("frosh-thumbnail-processor-info-texts",{template:s.a})},iRd4:function(e,t,a){}},[["RsLZ","runtime","vendors-node"]]]); \ No newline at end of file diff --git a/src/Resources/views/storefront/utilities/thumbnail.html.twig b/src/Resources/views/storefront/utilities/thumbnail.html.twig index 20e878d..6770996 100644 --- a/src/Resources/views/storefront/utilities/thumbnail.html.twig +++ b/src/Resources/views/storefront/utilities/thumbnail.html.twig @@ -24,7 +24,12 @@ {% set container = 100 %} {% set sizes = sizes|merge({ 'xl': (container / columns)|round(0, 'ceil') ~'vw'}) %} {% else %} - {% set container = 1360 %} + {% set defaultContainerMaxSize = shopware.config.FroshPlatformThumbnailProcessor.config.DefaultContainerMaxSize %} + {% if defaultContainerMaxSize is defined %} + {% set container = defaultContainerMaxSize %} + {% else %} + {% set container = 1360 %} + {% endif %} {% set sizes = sizes|merge({ 'xl': (container / columns)|round(0, 'ceil') ~'px'}) %} {% endif %} {% endif %}