Copied to clipboard

Flag this post as spam?

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


  • Sonja 123 posts 591 karma points
    Nov 15, 2018 @ 05:53
    Sonja
    1

    Displaying image in Umbraco

    Hi I have image in a nested content and with

    myNestedContentItem.GetProperty("myImg").DataValue
    

    I'm getting

    "umb://media/781a5e051a3e4042bc4f184e968f1b4f"
    

    how do I put this value to get valid html, something that will display the image in

    <img src="~/images/12.jpg">
    

    Thanks

  • Dennis Adolfi 1054 posts 6228 karma points MVP c-trib
    Nov 15, 2018 @ 06:33
    Dennis Adolfi
    100

    Hi Sonja.

    Your property "myImg", what is the datatype? MediaPicker?

    In that case you could try:

    var media = myNestedContentItem.GetPropertyValue<IPublishedContent>("myImg");
    <img src='@media.Url'>
    

    Best of luck to you!

Please Sign in or register to post replies

Write your reply to:

Draft