I want to iterate through the media section and check each media item to determine if it has been added to a page. E.g. has the media item added to the page using media picker,
Want to iterate through the media folder and check if the media item is included on the page or not so will know wether or not the media item is being used.
In the nexu gui you can run something to re create all the link usages. Also it will setup events so that when item is saved it will then add the link.
How do you check if a media item is being used on a page?
Hi,
does anyone know how to do this in code?
thanks!
Hi Damon,
I think we might need a bit more info for this one. Can you elaborate on what it is you're trying to do exactly?
Thanks,
Ben
Hi Ben,
I want to iterate through the media section and check each media item to determine if it has been added to a page. E.g. has the media item added to the page using media picker,
thanks,
You could try a package like Nexu that can track usage: https://our.umbraco.com/projects/backoffice-extensions/nexu/
Hi Damon,
The IPublishedContent object has extention methods for checking properties of the content.
you could use:
So you could try doing
See this link for more details:
Hope this helps :)
Louis
Hi Louis,
dont think that is what is required.
Want to iterate through the media folder and check if the media item is included on the page or not so will know wether or not the media item is being used.
Ok, I get it now...
I don't think there is a way to programatically check that. But try this package...
The description says
Hi Louis,
do you know if this package will work straight away or does each page have to be saved to create the relation?
thanks,
Damon
In the nexu gui you can run something to re create all the link usages. Also it will setup events so that when item is saved it will then add the link.
Regards
Ismail
Hi Damon
The package has two elements to it.
You can also set a couple of switches to prevent deletion or unpublishing of content if it is linked
is working on a reply...