Copied to clipboard

Flag this post as spam?

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


  • Andrew Hopkins 21 posts 133 karma points
    Oct 04, 2019 @ 10:37
    Andrew Hopkins
    0

    Can't get Media or Single Picker Value in Macro just umb media & umb document value

    I'm sure it's a simple solution but with little Macro documentation on version 8, I'm stuck in a rutt! Any suggestions would be gratefully received. I can only get the umb document values and umb media value.

       @inherits Umbraco.Web.Macros.PartialViewMacroPage
    @{
        var image = Model.MacroParameters["image"].ToString();
        var iUrl = Model.MacroParameters["internalUrl"].ToString();
    }
    <a href="@iUrl"><img class="img-responsive" style="width:100%" src="@image" /></a>
    

    ;)

  • Andrew Hopkins 21 posts 133 karma points
    Oct 04, 2019 @ 13:56
    Andrew Hopkins
    1
    @using ContentModels = Umbraco.Web.PublishedModels;
    @using Umbraco;
    @using Umbraco.Web;
    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    @{
        var image = Model.MacroParameters["image"];
        var mediaItem = Umbraco.Media(image); 
        var imgUrl = mediaItem.Url;
    
         var internalLink = Model.MacroParameters["internalUrl"];
         var link = Umbraco.Content(internalLink);
    }
    <a href="@link.Url"><img class="img-responsive" style="width:100%" src="@imgUrl" /></a>
    

    Sorted :)

Please Sign in or register to post replies

Write your reply to:

Draft