In this post I will explain how you can refresh renditions, both the OOTB existing Content Hub feature and how to programmatically do this, to get a good idea on refresh renditions, I would suggest you first read this blog post before going through this one. we will talk about mass edit jobs, processing job and limitation of the existing OOTB and how you can overcome this.
Sitecore Content Hub offers an OOTB feature where you can mass refresh renditions for assets, the two limitation of this OOTB feature is, its manual process, you have to manually select the assets you want to refresh renditions for, this need to be done after adding or updating media processing settings, and the second limitation is the number of assets that can be refreshed at each time.
Someone may ask, why the mass refresh renditions is manual? I had the same question, and this has been disabled for performance purposes, its better to control when to and what assets to be processed over an auto refresh renditions BUT Sitecore Content Hub already offers internal and external integrations that you can use to create you own jobs and refresh renditions.
When you refresh rendition for as example two assets, Sitecore Content Hub will create a Mass Edit job with [Stylelabs.M.Base.MassEdit.RefreshRenditionsOperation, Stylelabs.M.Base] as you can see from the following screenshot:
And of course you will need to pass the asset Ids which called targets in this scenario, and for each target the mass edit will create a processing job which will process the target assets and create a renditions for it, see the following screenshots for more information:
But what if you want to do some auto way to refresh renditions where you control when and what to be processed. then you need a custom script, or an azure function to choose what assets with a missing renditions and refresh renditions for, of course you will compare existing renditions for the asset when the media processing flow using the extension and target it if needed.
Now, You can go through the following flow:
- Loop through the existing assets.
- Based on the asset extension you can check the media processing renditions needed.
- Then you can read renditions from the asset and compare
- If missing rendition found, you need to add the asset Id to the list to be processed.
- Once you have your list, you can create M.Job entitiy and pass the job type (refresh renditions) and target Ids through the Json format.
No comments:
Post a Comment