sitegeist / sms-responsive-images

This TYPO3 extension provides ViewHelpers and configuration to render valid responsive images based on TYPO3's image cropping tool.
GNU General Public License v2.0
34 stars 18 forks source link

Upscaled images when srcset bigger than image width #57

Closed rupasix closed 4 years ago

rupasix commented 4 years ago

Typo3 9.5.13 plugin: 1.3.0 The plugin creates enlarged images when the srcset values are larger than the width of the original image. The same happens when I use the width or maxWidth parameter. I would expect that if the width of the original is exceeded, the original or image with the width / maxWidth parameter should be returned. In installtool I have processor_allowUpscaling disabled.

rupasix commented 4 years ago

Sorry, my mistake. After disabling processor_allowUpscaling I still had to delete all files from the processed folder and it works ok. Now I have a problem the other way round - using the crop and breakpoints parameter together with width / maxWidth the original image for higher srcset is returned. I would expect maxWidth to be included here and used for breakpoints and srcset greater than this value. In the example below I use a 408px image, I gave it maxWidth 60px.

<picture>
  <source 
    srcset="
    /fileadmin/_processed_/4/a/csm_concept2_e7f721ce26.png 400w, 
    /fileadmin/_processed_/4/a/csm_concept2_bcdfe8394e.png 407w" 
    media="(min-width:1200px)" sizes="(min-width: 60px) 60px, 100vw">
  <source 
    srcset="/fileadmin/dummy/concept2.png 408w" 
    media="(min-width:768px)" sizes="(min-width: 60px) 60px, 100vw">
  <source 
    srcset="
    /fileadmin/_processed_/4/a/csm_concept2_ecb6b84ea0.png 400w, 
    /fileadmin/dummy/concept2.png 408w" sizes="100vw">
  <img class="image-embed-item" src="/fileadmin/_processed_/4/a/csm_concept2_9d83bdfe6f.png" alt="" width="60">
</picture>

Crop breakpoints settings:

  0 {
    cropVariant = default
    media = (min-width:1200px)
    srcset = 1200,1600,1920
  }
  1 {
    cropVariant = tablet
    media = (min-width:768px)
    srcset = 800,1000
  }
  2 {
    cropVariant = mobile
    srcset = 400,600
    sizes = 100vw
  }

Edit: To clarify, i would expect result like that:

<picture>
  <source
    srcset="/fileadmin/_processed_/4/a/processed_to_60px_cropped_default.png 60w"
    media="(min-width:1200px)" sizes="(min-width: 60px) 60px, 100vw">
  <source
    srcset="/fileadmin/_processed_/4/a/processed_to_60px_cropped_tablet.png 60w"
    media="(min-width:768px)" sizes="(min-width: 60px) 60px, 100vw">
  <source
    srcset="/fileadmin/_processed_/4/a/processed_to_60px_cropped_mobile.png 60w" sizes="100vw">
  <img class="image-embed-item" src="/fileadmin/_processed_/4/a/processed_to_60px.png" alt="" width="60">
</picture>
rupasix commented 4 years ago

I'm afraid it's my fault. I misunderstood along with media,srcset and sizes. Additional images are created but using maxWidth will never be downloaded by the browser and this is the desired effect. I'm sorry for the trouble.

s2b commented 4 years ago

No problem. Sometimes it helps to just write it down. :-)