There are few ways to delete derived assets via the UI and API.
Via API
- Delete derived resources by public id
- Delete derived resources by transformation
- Delete derived resources by derived id
- Delete all derived resources in the account
Via UI
Via API
Delete derived resources by public id
In order to bulk delete derived assets using the Admin API, you can set the parameter keep_original
to true
, this ensures that only derived assets are deleted. For example, (in Rails):
Cloudinary::Api.delete_resources(['image1', 'image2'], :keep_original => true)
You can choose to delete only derived assets of a certain type, for example - Facebook fetched profile images:
Cloudinary::Api.delete_all_resources(:type => :facebook, :keep_original => true)
Delete derived resources by transformation1
You can choose to delete derived assets that use a particular transformation, for example - w_200,c_limit
:
Cloudinary::Api.delete_resources(:public_ids => ['sample1','sample2'], :transformations => "w_200,c_limit")
Delete derived resources by derived id
Delete assets by their derived IDs. The derived IDs can be retrieved by getting the details of a single resource.
Cloudinary::Api.delete_derived_resources(['cb4eaaf6503','a7b2a2756ab'])
Delete all derived resources in the account1
You can also use the delete_all_resources
method to bulk delete all derived assets of your uploaded assets in batches of 1000 assets per call. For example:
Cloudinary::Api.delete_all_resources(:keep_original => true)
1 When there are still more assets to go through, the next_cursor
value is returned as part of the response. You can then specify this value as the next_cursor
parameter of the following call. This way you can go through the full list of your assets.
For more information, see: http://support.cloudinary.com/hc/en-us/articles/205714121-How-do-I-browse-through-all-resources-in-my-account-using-the-API-
Via UI
You'll need to be logged into your Cloudinary account to perform the following actions:
Delete derived assets individually
- Click on the Media Library tab
- Select the asset and click on the
Advanced Editing
icon - Click on the
View derived images/videos
button that's right above the asset. - On the left-hand side, there will be options to delete the derived versions.
Bulk delete derived
- Go to your bulk delete page under your account settings here.
- Select the
derived resources only
options. - Select the specific
resource_type
andtype
of assets you want to delete then click theNext
button, this will submit the bulk delete request. An email notification will be sent out when the job is complete.
Here is a short video demonstrating how to delete derived assets via the UI:
Comments
15 comments
Does delete_all_resources() can be used with a tag filter (delete_all_resources_by_tag() ?)
Deleting all resources sharing a certain tag can be performed with the
delete_resources_by_tag
Admin API method, e.g., in PHP:$api->delete_resources_by_tag("mytag");
For more information:
http://cloudinary.com/documentation/admin_api#delete_resources_by_tags
Note that each call deleted up to 1000 resources.
I deleted the resource (containing an incorrect image) before I realized that it wouldn't automatically delete the derived images. Is there any way to delete the derived resources of that now deleted resource? I deleted and recreated the resource, assuming all derived resources would be deleted. Obviously, it doesn't list the derived resources under the new resource, though the URLs are still live and showing an incorrect image.
It seems like I now have no way to delete those "orphaned" resources.
Thanks
Hi Forrest.
Indeed deleting an image also deletes all its derivatives as well. However, note that both the original and the derived images might be still cached in the CDN.
For more information:
http://support.cloudinary.com/entries/23310776-I-have-deleted-an-image-and-though-it-has-been-removed-from-the-media-library-it-is-still-available-
If you want the purge the CDN as well, you should set the
invalidate
parameter totrue
while deleting, for example in Rails:Cloudinary::Uploader.destroy('my_image', :invalidate => true)
Deleting via the Media library automatically invalidates the image. Note that it may take up to an hour for the invalidation to fully propagate through the CDN.
Thank you Itay-
Does the API call purge the CDN any faster than doing it through the Media Library?
Many thanks
Invalidating either through the Admin API or the Media library may both take up to an hour. Note that this requests to propagate through Akamai's entire CDN network (100K+ servers in less than 1 hour).
We warmly recommend to include the version component as part of the URL. Cloudinary's 'version' is a simple "cache busting" solution that acts as a unique name for each uploaded image. Unlike invalidation, 'versions' instantly bypasses all cached versions and force the delivery of the latest version of the image.
For more information:
http://support.cloudinary.com/entries/23663103-What-are-image-versions-
Hi I have already set invalidate to "yes" under advanced settings. However, I am still getting the cache of the previous photo when i upload a new image with the same image name. I do not wish to keep track the version in the url and I would like to get the latest image just with the same URL. Could you help me with this? By the way I am using .Net.
Thank you very much.
[UPDATE]
I managed to resolve this issue by storing the version as I realized that no matter what version I provide in the URL e.g. "/v1" or "/v1486331234", it will return the latest image. Thanks
Hi Aster,
By default URLs that contain version components aren't invalidated.
More information about the default invalidation policy is available here: https://support.cloudinary.com/hc/en-us/articles/209048985-Why-wasn-t-my-URL-properly-invalidated-
If you're still encountering issues, please open a support ticket so we can look deeper into your use case.
It seems exceptionally flawed that deleting derived resources by derived id lets you do a bulk delete, however no bulk search for derived ids is indicated.
Hey there Jamie,
If you know the transformation that you would like to delete assets for you can use the api find all associated derived assets by using our transformation details method.
If you're not sure which transformations you're currently using you can always get all transformations first and then iterate through them.
If you still run into any issues finding a specific resource please open a support ticket so we can help.
This is the exact problem, if you have multiple transformations you need to delete resources for, iteration is unavoidable. This forces many admin api calls regardless of the bulk deletion method.
It would be fantastic to see a bulk transformation details method or to optionally include derived asset ids when getting all transformations to resolve this issue.
The use case for when this can happen is chained named transformations due to independent variables both adding a named transformation. For example if you were to have a named transformation to crop a video to 1080p, and a named transformation to add captions. It makes sense to have the cropping and captioning named transformations separate and chain them together as they should both be valid separately.
Hi Jamie,
Thank you for the response.
As the feature to bulk delete derived resources via API is not currently supported,
I have submitted a feature request internally to see if it can be added to our roadmap.
Please also feel free to suggest this on our [public roadmap](https://cloudinary.com/roadmap)!
Please let me know if there is anything else I can help you with!
Best,
John
Hi John,
Slightly confused here as the "delete_derived_resources" api lets you bulk delete 100 derived assets at a time from derived id - the issue is batch fetching the derived ids to use this method.
Hi Jamie,
Apologies for the confusion, I was responding with the details from our previous conversations in mind. In that conversation, you have two named transformations, i.e. `t_eng_caption` and `t_crop_for_customer`. In your transformations, you usually chain them - `t_eng_caption/t_crop_for_customer`. The request I opened was for the delete_derived_resources API to be able to accept `*t_crop_for_customer*` as a parameter and delete the derived along with its permutations.
As you already know, `delete_derived_resources` has a prerequisite to iterate through necessary public_ids to get the derived `id` using the resource API.
The feature request I submitted is to help with this use case, however, we cannot guarantee any ETA for it.
Hope this clarifies the confusion.
Hi John,
Thanks for the clarification, that makes sense. Yes a wildcard like `*t_crop_for_customer*` would also be a very good and concise solution to the issue of permutations when chaining named transformations. Thanks for opening that request, will make things easier in the future.
Please sign in to leave a comment.