Find references to a media file

Hi,

I’m trying to find a way to obtain all usages of a mediafile. I can use MediaService.GetFileReferences or MediaService.GetFileReferenceCount but that will not tell me if the file is being used in a texteditor, for example. Is there a way to get ALL references to an image (including, for example texteditor fields)?

Litium version: 7.6.3

No it will not expose the ones used in TextEditors.

Yeah, I get that. I was asking for a way to get them as well when searching for references :slight_smile:

Basically I need a way to find “unused” media on our site but I’m struggling to find a way.

Best,
Mårten

One way would be to query the database and the TextValue column of the Sites.PageFieldData and Sites.DraftPageFieldData tables. For each media file check if there’s any row where the TextValue column contains the media file id(guid) without the dashes.

Be cautious with querying the DB since it can affect the performance and crash the website, depending on too many rows and calculations.
Also there is a feature for this in the pipeline in future.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.