Replacing an image programatically

Hi Folks, I'm a front end dev at, we use Prismic for CMS, which is working great.

Is there a way to replace one image with another in the Media library programmatically? Maybe via an API request or something? Ideally we would like to replace an image in one spot and have it be updated on all pages where it is used. Or do I need to download all the Prismic JSON and do some sort of find and replace?

Hi Anton,

To do such a bulk action, you probably need to use the Prismic Import/Export feature to download all the docs, do a bulk action and then re-import them.

One another workaround that I haven't tested would be to delete the old image and import a new image with the same name (that can be help full if you will not use the old image anymore).

I will check with my team about the second option, do some tests, and get back to you.


Thanks! Yea the second option would great if its doable, it would be much quicker. If not I have worked with Prismic Import/Export before, and could figure out the right bulk find/replace for the downloaded JSON.

Hi Fares, I was wondering if you had any luck testing the second option you mentioned, where you delete an old image and import a new image of the same name.

Hi Anton,

I've done some tests and it turns out that the second option is not valid because the image gets copied in a new version once the image gets added to a document.