How can I resize the images when I import the product to store with graphql?

Edith_Jenkins
Tourist
7 0 1

Hi, everyone. 

I am newbie to shopify platform.

I am building the shopify app with shopify admin graphql and react.

But I have one problem.

When I import the product with some images(those are the external image) to my own store with graphql, I want to resize(width and height) those images and import project with resized images(new url or other).

What is the best way to solve this problem(without other shopify app)?

Please help me asap.

Best regards and thank you.
  

0 Likes
Greg_Kujawa
Shopify Partner
1016 83 221

According to the Shopify GraphQL API documentation you should be able to pass a transformedSrc field set into the image that's created on Shopify's end. See the docs --> https://shopify.dev/docs/admin-api/graphql/reference/common-objects/image#fields-2021-01. Hope this helps!

0 Likes
Edith_Jenkins
Tourist
7 0 1

Thank you @Greg_Kujawa 

But when I import the project with images to store with graphql, the valid fields of images are only id, altText, src.(ImageInput)

 

0 Likes
Greg_Kujawa
Shopify Partner
1016 83 221

If this field set isn't available when adding new images via the GQL API you might have to resize them in code before loading into Shopify. Assuming you have access to JavaScript in your environment then there are many ways to accomplish this. Such as --> https://stackoverflow.com/questions/23945494/use-html5-to-resize-an-image-before-upload

0 Likes
Edith_Jenkins
Tourist
7 0 1

What I need to import product with resized image to store is only image URL. but I can't get the new URL  via the method you mentioned (I think).

There are not a lot ways to get the new URL from the external image URL.

 

0 Likes