In Umbraco 8.6 you can now see where a media item is used directly on the media in the media section - that's is excellent and I love it.
How do I retrieve that information via the API/services?
I need to know which other items is using a media item, at the time the media item is saved (or deleted).
I need this because I need to handle those items aswell, when the media is updated
I've now been looking at how it's done in the core and it's using the RelationService
Services.RelationService.GetPagedParentEntitiesByChildId(int id, long pageIndex, int pageSize, out long totalChildren, params UmbracoObjectTypes[] entityTypes)
Where entityTypes is fetched with ObjectTypes.GetUmbracoObjectType(entityType);
entityType being DOCUMENT, MEDIA or MEMBER
How to retrieve media usage?
In Umbraco 8.6 you can now see where a media item is used directly on the media in the media section - that's is excellent and I love it. How do I retrieve that information via the API/services?
Hi Rasmus
Do you want to use media in the backoffice or externally?
Alex
It's I have an eventhandler
MediaService.Saved += MediaServiceOnSaved;
and for each saved entity I want to know which other items the media is used inBut event handler isn't API, so you need to track changes in media items?
Yeah. That's why I wrote /Services :-)
I need to know which other items is using a media item, at the time the media item is saved (or deleted). I need this because I need to handle those items aswell, when the media is updated
You can use Nexu to track changes - https://our.umbraco.com/packages/backoffice-extensions/nexu/
The relation must be there already, since it's shown OOTB in 8.6 Guess I'll have to look in the source :-)
Hi Rasmus,
There is a service you can use, its called the 'RelationService' I think.
-Joep
I've now been looking at how it's done in the core and it's using the RelationService
Where entityTypes is fetched with
ObjectTypes.GetUmbracoObjectType(entityType);
entityType being DOCUMENT, MEDIA or MEMBERis working on a reply...