Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Rocoeh 65 posts 86 karma points
    Oct 08, 2012 @ 18:14
    Rocoeh
    0

    Check a media item exsits

    Havng trouble, with this, I need to check the media picked item (an image) exists and if it does render it out. 

    I get a generic macro error, if I do not wrap it in the if statement and the image has been picked it works.

     @{
      
    if(@Model.audioImage != null) {
    dynamic image = new umbraco.MacroEngines.DynamicMedia(@Model.audioImage);
    <img src="@image.umbracoFile" width="270" height="178" />
                         }
                                          
     }

     

     

     

     

     

     

     

     

     

     

     

     

     

  • Fuji Kusaka 2203 posts 4220 karma points
    Oct 08, 2012 @ 19:02
    Fuji Kusaka
    0

    Hi Rocoeh,

    Try changing this 

    if(@Model.audioImage != null) {
         dynamic image = new umbraco.MacroEngines.DynamicMedia(@Model.audioImage);
         <img src="@image.umbracoFile" width="270" height="178" />
     }


    to

    var img = @Model.Media("audioImage","umbracoFile");
    if(!String.IsNullOrEmpty(@img)){
    <img src="@img" />
    }

     

    Hope this helps

     

    //fuji

     

  • Rocoeh 65 posts 86 karma points
    Oct 09, 2012 @ 12:30
    Rocoeh
    0

    That was perfect. Thanks,

  • Fuji Kusaka 2203 posts 4220 karma points
    Oct 09, 2012 @ 12:57
    Fuji Kusaka
    0

    Great if i could help...

     

    //fuji

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies