This work can be splitted into two part, first part is Sitecore and then is .Net MVC.
Sitecore Part
Fist, you have to upload your images to Editor platform under the Media Library, a suggestion is you can create a specific folder to put relative images in oder to quick search.
There is a field required but I miss cause View empty output. The Alt field must be assigned a value.
Finally this media item can be used in content
.Net MVC Part
Please create a static class named as MediaExtensions (or whatever you want), then create a function call getUrl which require a field name parameter input, put the following code into function.
if you complete above coding, then you can start to use it at View.
Reference :
https://sitecore.stackexchange.com/questions/1230/how-do-you-get-the-link-for-a-media-item/1251
https://stackoverflow.com/questions/6122901/get-media-url-including-server-part
沒有留言:
張貼留言