Join us for an upcoming Shopify Partner webinar on February 27, 2024. Discover the latest Checkout Extensibility features, and deep dive on improvements to Shopify Functions and Web Pixels. Register now for either the 10am EST or 2pm EST sessions.
Solved

Why Do Some Images Always Have A UUID Appended?

friendscottn
Shopify Partner
10 2 2

I noticed while uploading images via the fileCreate mutation that some images would have a UUID appended no matter what value I would specify for the duplicateResolutionMode.

 

mutation:

 

    mutation fileCreate($files: [FileCreateInput!]!) {
        fileCreate(files: $files) {
            files {
                ...file
            }
            userErrors {
              field
              message
            }
        }
    }

 

variables:

 

{
    "files": [
        {
            "alt": "Alt Text",
            "contentType": "IMAGE",
            "duplicateResolutionMode": "REPLACE",
            "filename": "some_image_thumb.jpg",
            "originalSource": "https:\/\/www.myimages.com\/some_image_thumb.jpg"
        }
    ]
}

 

 

Accepted Solution (1)

friendscottn
Shopify Partner
10 2 2

This is an accepted solution.

The key was the "_thumb.jpg" at the end of the filename. If you change the filename by removing the "_thumb" you can work around the bug in the API and your REPLACE or RAISE_ERROR duplicateResolutionMode will be honored.

 

There is a similar bug for files ending in underscore followed by digits. For example: "_1000.jpg" and "_1000x600.jpg" as well. Removing this these trailing patterns from the filename field allows you work around this issue. The originalSource field can continue to have the "_thumb" or "_1000" patterns included.

 

So this will work:

{
    "files": [
        {
            "alt": "Alt Text",
            "contentType": "IMAGE",
            "duplicateResolutionMode": "REPLACE",
            "filename": "some_image.jpg",
            "originalSource": "https:\/\/www.myimages.com\/some_image_thumb.jpg"
        }
    ]
}

The resulting upload will be at 

https://cdn.shopify.com/s/files/1/{ACCO/UNTN/UMBER}/files/some_image.jpg?v={timestamp}

View solution in original post

Replies 2 (2)

friendscottn
Shopify Partner
10 2 2

This is an accepted solution.

The key was the "_thumb.jpg" at the end of the filename. If you change the filename by removing the "_thumb" you can work around the bug in the API and your REPLACE or RAISE_ERROR duplicateResolutionMode will be honored.

 

There is a similar bug for files ending in underscore followed by digits. For example: "_1000.jpg" and "_1000x600.jpg" as well. Removing this these trailing patterns from the filename field allows you work around this issue. The originalSource field can continue to have the "_thumb" or "_1000" patterns included.

 

So this will work:

{
    "files": [
        {
            "alt": "Alt Text",
            "contentType": "IMAGE",
            "duplicateResolutionMode": "REPLACE",
            "filename": "some_image.jpg",
            "originalSource": "https:\/\/www.myimages.com\/some_image_thumb.jpg"
        }
    ]
}

The resulting upload will be at 

https://cdn.shopify.com/s/files/1/{ACCO/UNTN/UMBER}/files/some_image.jpg?v={timestamp}
Liam
Shopify Staff
2664 287 726

I'm glad you figured this out and thanks for coming back to post the answer!

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog