Shopify Theme Development - Help me understand the 'files' URL

I am developing a section that will need to pull images through from the 'files' folder.

I will have images a.png, b.png & c.png all saved within the 'files' folder. I will then loop through an array of image names array = [a,b,c].

My first question is, as I loop through am I able to go to one of the 'files' directories, say for a.png with the file location of file:///cdn.shopify.com/s/files/1/0043/0886/0977/files/a.png

Can I grab the start of the file URL file:///cdn.shopify.com/s/files/1/0043/0886/0977/files/ then put an a the value from the array in at the end? file:///cdn.shopify.com/s/files/1/0043/0886/0977/files/ + array[0] + .png

The above is just how I plan to use the variable and already have successful code so long as the 'files' URL start remains the same, but can anyone explain the files URL to me? file:///cdn.shopify.com/s/files/1/0043/0886/0977/files/ What is the /s/ + /1/ + /0043/ + /0886/ + /0977/?

1 answer

  • answered 2019-08-14 09:41 drip

    Yes they will be unique to your store here is a sample from a test store of mine

    https://cdn.shopify.com/s/files/1/0705/0149/files/mobile-receipt-debit.png

    Nothing is the same (except the files and 1).

    If you plan to change them with JS you will need to use RegEx and swap only the name part of the image.