I am on Umbraco v7.4 on one site and v7.10 on another.
On v7.10, I created an image parameter in my Partial View that allows a user to add an image to a macro that brings in the image src. The code for that is below.
@{
var svcIconMain = Model.MacroParameters["ServiceIconFront"];
var mediaItemOne = Umbraco.TypedMedia(svcIconMain);
<img src='@mediaItemOne.GetPropertyValue("umbracoFile")' alt='' class="front-icon"/>}
Conversely, when I add that same code to 7.4 nothing is output, rather I get an error. I will say, 7.10 I am using the "Content Picker" type for my Macro, while I am trying to use "Single Media Picker" for the 7.4 (They don't have content picker for 7.4). I cant seem to find a way to add an image into a Macro on 7.4 and I have found nothing in the forum/YouTube/Umbraco.tv . So I guess I will ask first, is this not an acceptable way to be using a Macro in the first place, or is the solution just simple enough where I am totally missing something? Thanks in advance!
in your 7.4 site, what is the value of the svcIconMain variable? (just write that bit out) eg are you able to read a value from the ServiceIconFront macro parameter, when it is using the Single Media Picker type?
If you are getting an Id here, then your picker is working, and Umbraco.TypedMedia should return the Media item related to that Id.
Finally I'd change the way you write out the img src attribute to be
@mediaItemOne.Url
the umbracoFile property can either be the url of the image or it can be a JSON blob containing image crop information depending on how you have that property configured, but the .Url helper will always return the Url.
Single media Picker for Macro
I am on Umbraco v7.4 on one site and v7.10 on another.
On v7.10, I created an image parameter in my Partial View that allows a user to add an image to a macro that brings in the image src. The code for that is below.
Conversely, when I add that same code to 7.4 nothing is output, rather I get an error. I will say, 7.10 I am using the "Content Picker" type for my Macro, while I am trying to use "Single Media Picker" for the 7.4 (They don't have content picker for 7.4). I cant seem to find a way to add an image into a Macro on 7.4 and I have found nothing in the forum/YouTube/Umbraco.tv . So I guess I will ask first, is this not an acceptable way to be using a Macro in the first place, or is the solution just simple enough where I am totally missing something? Thanks in advance!
Hi Mike
in your 7.4 site, what is the value of the svcIconMain variable? (just write that bit out) eg are you able to read a value from the ServiceIconFront macro parameter, when it is using the Single Media Picker type?
If you are getting an Id here, then your picker is working, and Umbraco.TypedMedia should return the Media item related to that Id.
Finally I'd change the way you write out the img src attribute to be
@mediaItemOne.Url
the umbracoFile property can either be the url of the image or it can be a JSON blob containing image crop information depending on how you have that property configured, but the .Url helper will always return the Url.
regards
Marc
that worked. Thanks!
is working on a reply...