Copied to clipboard

Flag this post as spam?

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


  • ChuDatCN 12 posts 62 karma points
    Oct 07, 2022 @ 07:59
    ChuDatCN
    0

    Get image from Partial View Macro Files

    Hi, I'm using Media Picker as a Marco's Parameter. enter image description here

    and I want to print out image after i choose from Marco in RTE .

    @inherits Umbraco.Cms.Web.Common.Macros.PartialViewMacroPage
    @{
       imagePosition = Model.GetParameterValue<string>("imagePosition","full-width");
    }
       <li>@imagePosition </li>
       <li>@Model.MacroParameters["image"]</li>
    

    but the image has odd url as: " umb://media/e72e191adc2a4593ae9449c7fda176ad "

    So how can i get image from PartialViewMacroPage.

    Thanks

  • mizzle 90 posts 325 karma points
    Oct 07, 2022 @ 19:29
    mizzle
    101

    I was able to retrieve an image with

    var media = Umbraco.Media(Model.MacroParameters["image"]).Url();
    <img src="@media" />
    

    Is this what you were after?

  • ChuDatCN 12 posts 62 karma points
    Oct 13, 2022 @ 08:38
    ChuDatCN
    0

    It worked perfectly.

    Thank you

Please Sign in or register to post replies

Write your reply to:

Draft