I am using Archetype (quite successfully so far) but I am unable to get the path of my single media picker image I have chosen! All I can return the is "Value" of the image and I have googled extensively and cannot find a solution to this, my code is below:
@foreach (var fieldset in Model.Content.GetPropertyValue<ArchetypeModel>("myArch")) {
var imageUSP = @Umbraco.TypedContent(fieldset.GetValue("uspImage"));
@imageUSP
}
The "@imageUSP" returns the Value of 1077 - in this example. I've tried appending .Url and .ImageUrl and I cannot for the life of me figure out how to get the path from here!
What version of Umbraco are you using? If it's 7.6 then follow Paul's guide on his site.
Otherwise Umbraco.Media().Url should work, as that number you're seeing is the content id.
Edit: also you shouldn't need the extra "@"'s when declaring inside the foreach when at the top of the function. (I know I put it in my example by accident)
Archetype and media picker (going insane)
Hello,
I am using Archetype (quite successfully so far) but I am unable to get the path of my single media picker image I have chosen! All I can return the is "Value" of the image and I have googled extensively and cannot find a solution to this, my code is below:
The "@imageUSP" returns the Value of 1077 - in this example. I've tried appending .Url and .ImageUrl and I cannot for the life of me figure out how to get the path from here!
Any help would be wonderful
Thanks, Garry.
Hi Garry Try this:
http://www.codeshare.co.uk/blog/how-to-get-the-file-path-of-a-media-item-in-umbraco/
Kind regards
Paul
What version of Umbraco are you using? If it's 7.6 then follow Paul's guide on his site.
Otherwise Umbraco.Media().Url should work, as that number you're seeing is the content id.
Edit: also you shouldn't need the extra "@"'s when declaring inside the foreach when at the top of the function. (I know I put it in my example by accident)
Using Umbraco version 7.5.12 - I'll give it another crack with fresh eyes in the morning as it's driving me mental!
Cheers
Apologies, my first comment was utterly wrong (going to delete it).
What you want to do is:
var imageUsp = Umbraco.Media(fieldset.GetValue("uspImage")).Url
You can then pop that variable into an image source like so
"< img src="@imageUsp"/>"
Thank you Alex you're a star!
is working on a reply...