Image transformedSrc deprecated, how to replace?

taufiq_ssc
Visitor
1 0 0

Hello! Our public app fetches the webp version of product images via GraphQL transformedSrc, However, couple of weeks ago we noticed that a lot of images returned from the produced url are still in their original format, based on their content-type, eg: images/jpg

When i investigate the docs I found out the transformedSrc is being deprecated, as per this page:
https://shopify.dev/api/admin-graphql/2021-10/objects/image#fields-Image-OBJECT

"The location of the transformed image as a URL.

All transformation arguments are considered "best-effort". If they can be applied to an image, they will be. Otherwise any transformations which an image type does not support will be ignored. Use url(transform:) instead"

Is this the reason for the transformation not working?
When i tried to use url, I got error message that Image does not implement url field.
Can any of you help me solve this? How to avoid the deprecation?

Thank you

 

 

 

 

 

Is this the reason for our failure?


Link for

Replies 2 (2)

PublicApps
Shopify Partner
146 5 34

I've noticed this deprecation warning too in multiple places, e.g.:

Screenshot 2021-11-29 at 20.21.43.png

(This is from the GraphiQL in-app docs when using the Admin API version 2021-10.)

It says use `url` instead, but url is not a field on Image. Can't find anything on an url field in the docs on shopify.dev either.

Public Apps | Theme customization & App development
 - Was my reply useful? Like it to let me know!
 - Did I answer your question? Please mark as Accepted Solution.
 - Need more help? Contact us.

Kyon147
Shopify Partner
7 1 2

As the docs suggest, you need to use the transform.

 

So something like this:

 

 

featuredImage{
  url(transform:{preferredContentType: PNG})
}

 

 

There's a few things you can do with the transform, so take a look at the docs link to see what you can use.