Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Srcset no longer generates transforms larger than base transform with upscaleImages disabled #7352

Closed
Wiejeben opened this issue Jan 5, 2021 · 4 comments
Labels

Comments

@Wiejeben
Copy link
Contributor

Wiejeben commented Jan 5, 2021

Description

Encountered this bug in two fully unrelated projects after updating from 3.5.16 to 3.5.17.1. Both projects have upscaleImages disabled in the general.php, which I believe is the cause of this issue. Enabling upscaling would fix the srcset.

The image it is trying to transform is way larger than the resolution we need, so x2 should work.

Steps to reproduce

Example:

fragment srcset on AssetInterface {
  title
  url
  focalPoint
  srcset(sizes: ["2x"])
}

{
  entry(section: "pages", uri: "over-ons") {
    ... on pages_pages_Entry {
      doorway {
        ... on doorways_doorways_Entry {
          mainImage @transform(handle: "doorwayGlobal") {
            ...srcset
          }
        }
      }
    }
  }
}

Generated the following in 3.5.16

{
  "data": {
    "entry": {
      "doorway": [
        {
          "mainImage": [
            {
              "title": "Klantverhaal image",
              "url": "/uploads/images/_doorwayGlobal/klantverhaal_image.jpg",
              "focalPoint": [
                0.5,
                0.5
              ],
              "srcset": "/uploads/images/_626x548_crop_center-center_none/klantverhaal_image.jpg 2x"
            }
          ]
        }
      ]
    }
  }
}

However after updating to 3.5.17.1 it provides the following and no longer upscale our srcset:

{
  "data": {
    "entry": {
      "doorway": [
        {
          "mainImage": [
            {
              "title": "Klantverhaal image",
              "url": "/uploads/images/_doorwayGlobal/klantverhaal_image.jpg",
              "focalPoint": [
                0.5,
                0.5
              ],
              "srcset": "/uploads/images/_doorwayGlobal/klantverhaal_image.jpg 2x"
            }
          ]
        }
      ]
    }
  }
}

Additional info

  • Craft version: 3.5.17.1
  • PHP version: 7.4
  • Database driver & version: MySQL 5.7
  • Plugins & versions: -
@Wiejeben Wiejeben added the bug label Jan 5, 2021
@Wiejeben
Copy link
Contributor Author

Wiejeben commented Jan 6, 2021

To provide a bit more context, let's take an image that's 100x100 pixels.

Normally if I were to request that 100x100 image to be 500x500 image it would upscale that image, increasing its file size and providing me with a perfect 500x500 stretched(/pixelated?) image. Which depending on the CSS could be useful but in my scenario totally unnecessary since I can counter smaller image resolutions with some simple CSS, saving precious bandwidth.

With the possibility of setting upscaleImages to false I expect the above example to basically never happen. If I were to execute that same transform I expect to get back a 100x100 image because that's just as big as the source image is, cannot just "enhance" the resolution like you see in the movies and create details (AI is getting pretty good at that, but I digress haha).

Using srcset I expect this same behaviour. Lets say from that base 100x100 image I create a transform to 50x50, it would downscale that image to the desired resolution. However if I request an x2 on the same transform I expect srcset to generate me an image of 100x100 (which is still <= source image resolution). Normally if I were to then request an x3 image it would generate a 150x150, but with upscaleImages set to false I would expect this to provide me with a 100x100 image since thats the max resolution of its source and I won't want it to upscale the source image.

Let me know if this is clear and whether or not this is something that can be supported!

@Wiejeben Wiejeben changed the title Srcset no longer upscaling with upscaleImages disabled Srcset no longer generates transforms larger than base transform with upscaleImages disabled Jan 6, 2021
@andris-sevcenko
Copy link
Contributor

I'm unable to reproduce this on my end. I'll follow up over Discord and report back.

@andris-sevcenko
Copy link
Contributor

All fixed up for the next release. Thanks for reporting this!

@brandonkelly
Copy link
Member

Craft 3.5.18 is out now with that fix ✨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants