Dear All,
In our current project (Kentico 12.0.51 MVC dev model), each time we need to store a reference to Media Library's file in our Page Types, we create a field of Text Data Type and Media Selection Form Control.
Also, in the Settings Application, we have enabled the "Use permanent URLs" for media, under Content > Media section.
In this way, when we access the field in the API, all media file references are in the form: "/getmedia/dbc64d58-de28-4769-984c-cc55a13ab337/image.jpg?width=1136&height=639&ext=.jpg".
Instead of using the above value (url) directly on our views, we extract the GUID and run the following query in order to get the entire MediaFileInfo:
var file = MediaFileInfoProvider
.GetMediaFiles()
.OnSite(<siteName>)
.WhereEquals("FileGUID", fileGUID)
.FirstOrDefault();
We needed to get the whole MediaFileInfo structure instead of only the media file url, so as to introduce the alt attribute (MediaFileInfo.FileTitle) in the img tag.
Moreover in the Settings Application, under System > Performance in the "Server file caching" section there is the "Cache files (minutes):" setting set to 10 minutes. We expected that this setting would automatically cache queries against the MediaFileInfoProvider but it does not.
We have the following questions:
-
Is there any helper method that would provide the FileTitle that is associated with a Media File (e.g. an Image) directly on a View? In this way we would not have to make a query against the MediaFileInfoProvider.
-
What does the "Server file caching" do, and how can we make use of it?
-
What other way do we have in order to cache the requests for MediaFileInfo structures?
Thanks in advance,
George