Copied to clipboard

Flag this post as spam?

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


  • Hayden Tomas 11 posts 82 karma points
    Jan 07, 2019 @ 23:44
    Hayden Tomas
    0

    Media picker url output to template help!

    Hi guys,

    So I am an Umbraco newbie and practicing my templating. I want to create my own open graph section which will only display if the user chooses to fill in the data.

    So in my partial I have the following (I grabbed and modified the code from RankOne seo plugin)

        @if(Model.Content.HasProperty("ogImage") && Model.Content.HasValue("ogImage")){
    <meta property="og:image" content="@(Model.Content.GetPropertyValue<string>("ogImage"))"/>
    }
    

    code example

    I have uploaded the image as i am not sure if the code shows correctly! But this outputs a code value, not the url of the image when using the media picker.

    What do i need to do in order to make umbraco output the uploaded image url onto my template?

    Thanks!

  • Richard Eyres 98 posts 580 karma points
    Jan 08, 2019 @ 07:45
    Richard Eyres
    0

    I believe the image would be an iPublishedContent, so you could use the following:

    Model.Content.GetPropertyValue

  • 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