Displaying an image (media item) in Partial View Macros
Hi,
I am fairly new to Umbraco, and currently need to display some images on a template using a few partial view macros. I have been searching the forumns without much luck. I know this is a bit of hand holding, but can anyone guide me in how to do this specifially in macros? I am getting the image from the image picker, which returns the id. What is the next step?
Once you have the Id, then a call via the Umbraco helper to @Umbraco.TypedMedia(id) should give you an object with the properties you need to display the image.
You can get the MediaService in context. Its something like Services.MediaService then you can call GetById(id) which will get you the media object. You then need to get the "umbracoFile" property of that media object :). Charlie
Currently 6.1.6. thanks you all for your help. the info is very usefull. So far, from my little experience there is little info or documentation on partial view macros and or what additional namespaces i need to include..eg as Charles suggest, i would need the MediaService... that was the missing piece when i tried to use GetById(id). Thanks again guys!!!
Displaying an image (media item) in Partial View Macros
Hi,
I am fairly new to Umbraco, and currently need to display some images on a template using a few partial view macros. I have been searching the forumns without much luck. I know this is a bit of hand holding, but can anyone guide me in how to do this specifially in macros? I am getting the image from the image picker, which returns the id. What is the next step?
Thank you very much in advance!
Once you have the Id, then a call via the Umbraco helper to @Umbraco.TypedMedia(id) should give you an object with the properties you need to display the image.
What version of Umbraco?
You can get the MediaService in context. Its something like Services.MediaService then you can call GetById(id) which will get you the media object. You then need to get the "umbracoFile" property of that media object :). Charlie
Hi,
Currently 6.1.6. thanks you all for your help. the info is very usefull. So far, from my little experience there is little info or documentation on partial view macros and or what additional namespaces i need to include..eg as Charles suggest, i would need the MediaService... that was the missing piece when i tried to use GetById(id). Thanks again guys!!!
No worries, glad you got it solved.
If you could put a vote in for MVP that would be great :). Charlie
http://our.umbraco.org/people/mvps
is working on a reply...