I'm pretty sure, that media is indexed in the Internal index, so maybe you can reverse engineer through an Examine search.
var internalSearcher = ExamineManager.Instance.SearchProviderCollection["InternalSearcher"];
var query = internalSearcher.CreateSearchCriteria().Field("umbracoFile", "my-image.jpg").Compile();
var media = Umbraco.TypedSearch(query);
That would give en IEnumerable of IPublishedContents, where umbracoFile (the upload property) is equal to my-image.jpg.
Solid idea, I was thinking about something similar. However. I solved it with creating a folder in the project outside of umbraco, put the images there instead and mapped the folder and then just used
File.exists(mappedPath + filename + ".jpg")
If it existed I could just put a relative link in there (because I know the name of the folder), for example:
Get media file by filename
Hi!
Is it possible to get a media-content by filename? If so, how?
I'm pretty sure, that media is indexed in the Internal index, so maybe you can reverse engineer through an Examine search.
That would give en IEnumerable of IPublishedContents, where umbracoFile (the upload property) is equal to my-image.jpg.
Solid idea, I was thinking about something similar. However. I solved it with creating a folder in the project outside of umbraco, put the images there instead and mapped the folder and then just used
If it existed I could just put a relative link in there (because I know the name of the folder), for example:
Hope it helped anyone else.
is working on a reply...