How to upload article content images to shopify files

tsokol83
Shopify Partner
1 0 0

I am developing a tool that migrates blog post via Articles API.

HTML content I migrate of course have many <img src=""> tags. Is there a way I could force Arciles API to upload those images to shopify and replace a image path to cdn.shopify.com?

Or there is any other way of implementing it? As far as I know there is no FIles API I can use.

 

best regatrs

Tomasz

0 Likes
Ryan
Shopify Staff
Shopify Staff
486 42 109

Hi @tsokol83,

 

You can use the articles API to associate an image to an article or blog post, but not to upload them to Shopify.  If the image is a product image, you can upload it to the product first, and then associate it to the blog.  Otherwise hosting elsewhere and linking to the article is a good solution.

 

 

Developer Experience @ Shopify
0 Likes
The_Pack_Track
New Member
4 0 0

Hi,

I wanted to do the same thing so I created a blog called 'Images' and every time I needed to place an image in a blog I created an empty blog post in 'Images' with the image as the feature image, this works since the Article API (scroll to 'Create an article with a base64 encoded image') will allow you to create one feature image for a blog, I then used the returned feature image src in my real blog post.

I guess you could then go and delete the 'Image' blog posts or periodically delete them and I assume (but not certain) that the files would not be removed.

Another good idea would be to create a blog template for images which returns 404.

This does achieve the same end goal but it would be much better if there was a Files API to make this process a lot simpler.

Hope this helps someone,

Stu.

0 Likes