Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I am on Umbraco versoin 7.5.9.
I see from intellisense in Visual Studio 2017 that UmbracoContext.Current.MediaCache has these properties
GetAtRoot, GetById, GetByxPath, GetHashCode, GetSingleByXPath
I do not see one for "Name".
Does anyone know how to query the UmbracoContext.Current.MediaCache by name?
If you look at the implementation of the MediaCache here:
You'll see that methods like GetByXPath and GetSingleByXPath aren't implemented for Media,
(this is because Media content isn't stored in an XML file format in the same way that content is (otherwise you could have used either of those methods to create an XPath search for an element with nodeName attribute equal to your search.
The Media information is stored in the database, but there is an Examine Search layer over the top for speed.
There is a legacy approach called uQuery: https://github.com/umbraco/Umbraco-CMS/blob/1bb593d264a085f94a3ce3bd710392b350561430/src/Umbraco.Web/umbraco.presentation/umbraco/uQuery/uQuery-Media.cs
which has a GetMediaByXPath and GetMediaByName, but these will make a request to the db
what might be quicker is an Examine query of the media section?
So it depends a little on what you are trying to achieve? eg do you need to find a media item by name? could it be 'picked' or is it Search Media functionality...
sorry to be a bit vague!
Since all Umbraco Media is stored on the file system, here is what I did.
I uploaded the Media (PDF document) to the production media folder.
Its straight forward once you know this id.
So for each env (tst, stg, prd), I change the id value programmatically and I'm good to go.
Thanks for pitching it.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted