I have a media picker as one of my generic properties on a template page. I'm trying to get the file path to the image selected but I cannot figure out how to do this from any of the examples I've found. I can get all the other generic properties by simply calling @CurrentPage.someproperty to get a value. I can't do the same with a media picker. I only have the one on the page so can some one please help me do this?
version 7.1.4
Thanks,
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @{ Layout = "umbLayout.cshtml"; } @Umbraco.RenderMacro("InsertWidgit", new {mediaFile="[no clue how to access this from the media picker]", [email protected], [email protected]})
Thank you. I tried that example before but didn't see how to apply it for the render macro statement. All I needed to do was move my statement inside the @{ }. I'm not familiar with this kind of syntax.
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @{ Layout = "umbLayout.cshtml"; if(CurrentPage.HasValue("yourMediaPickerAlias")){ var dynamicMediaItem =Umbraco.Media(CurrentPage.yourMediaPickerAlias);
Media Picker as a Generic Property on a Template
Hi All,
I have a media picker as one of my generic properties on a template page. I'm trying to get the file path to the image selected but I cannot figure out how to do this from any of the examples I've found. I can get all the other generic properties by simply calling @CurrentPage.someproperty to get a value. I can't do the same with a media picker. I only have the one on the page so can some one please help me do this?
version 7.1.4
Thanks,
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
Layout = "umbLayout.cshtml";
}
@Umbraco.RenderMacro("InsertWidgit", new {mediaFile="[no clue how to access this from the media picker]", [email protected], [email protected]})
Hi Dan,
Something like this:
Jeavon
Thank you. I tried that example before but didn't see how to apply it for the render macro statement. All I needed to do was move my statement inside the @{ }. I'm not familiar with this kind of syntax.
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
Layout = "umbLayout.cshtml";
if(CurrentPage.HasValue("yourMediaPickerAlias")){
var dynamicMediaItem =Umbraco.Media(CurrentPage.yourMediaPickerAlias);
is working on a reply...