Cms: GraphQL transform doesn't work with size property of images

Created on 1 Feb 2021  路  1Comment  路  Source: craftcms/cms

Description

I have the following graphQL snippet:

images: bannerImages {
  url
  width
  height
  size
}
imagesSmall: bannerImages @transform(handle: "small") {
  url
  width
  height
  size
}

which results in the following output:

"images": [
  {
    "url": "http://127.0.0.1:10000/devstoreaccount1/assets/content-images/banners/banner-1.png",
    "width": 1382,
    "height": 922,
    "size": "2777441"
  }
],
"imagesSmall": [
  {
    "url": "http://127.0.0.1:10000/devstoreaccount1/assets/content-images/banners/_small/banner-1.png",
    "width": 170,
    "height": 50,
    "size": "2777441"
  }
]

As you can see above, the url, width & height properties are getting transformed, however, the size property is still showing the size of the original, hi-res file in the imagesSmall version instead of the size of the "small" transform (which is around 2000-3000 bytes in this case)

Additional info

  • Craft version: 3.6.1
  • PHP version: 7.3
  • Database driver & version: PGSQL 11
assets enhancement

Most helpful comment

That's not a GraphQL thing. Currently size always reflects the original image size, so I'll mark this as an enhancement.

This might also happen only for Craft 4.0, as that's a change in behavior that might be breaking for some if they don't expect the size field to reflect the transform filesize.

>All comments

That's not a GraphQL thing. Currently size always reflects the original image size, so I'll mark this as an enhancement.

This might also happen only for Craft 4.0, as that's a change in behavior that might be breaking for some if they don't expect the size field to reflect the transform filesize.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

michel-o picture michel-o  路  3Comments

mccombs picture mccombs  路  3Comments

angrybrad picture angrybrad  路  3Comments

michaelhue picture michaelhue  路  3Comments

angrybrad picture angrybrad  路  3Comments