How do i get the information in "Used by" on a file in Media?

A customer wants to present PDFs connected to Products on a page.
So we are planing to use a folder with the pdfs and present all pdfs inside that folder with sub folders.

But they would also like to present the product name and image the pdf is connected to.
So if i have a Litium.Media.File, how do i get “Used By” in the code?

(If we search every product with a file in the pdf field, we would not get the tree structure that the media folder gives us)

(I guess i can search the files from the PIM, and map the file name with the tree structure from media, but using Used by would be much easier)

image

Litium version: 7.7.1/8

The used by are calculated by the Litium.Media.IMediaReferenceService::FindReferences, this is an operation that going directly to database and should not be used on the public websites without implementing a cache for the result to avoid resolving the same references over and over again.

To be able to get all references you need to inject IEnumerable<IMediaReferenceService> into your service and for each of them call the FindReferences method.

2 Likes

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