Copied to clipboard

Flag this post as spam?

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


  • Tom 713 posts 954 karma points
    Aug 16, 2017 @ 07:32
    Tom
    0

    Umbraco 7 Webforms Display Image in Inline Macro

    Hi when using an inline cshtml macro if i spit the contents out to screen of say @item.photo it returns: umb://media/9086fdeed168494f82e8fc195999c7e2

    Just wondering how to convert that to an image url?

  • Alex Skrypnyk 6182 posts 24284 karma points MVP 8x admin c-trib
    Aug 30, 2017 @ 13:25
    Alex Skrypnyk
    0

    Hi Tom

    You see UDI this is new ids in Umbraco, it means that Umbraco Property Value converters are enabled in your project.

    Can you show all your code?

    THanks,

    Alex

  • Tom 713 posts 954 karma points
    Aug 31, 2017 @ 00:18
    Tom
    0

    Hi Alex, I ended up having to do something like this to display the photo.. is this the preferred way or is there something easier?

      @{
    int photoId = 0;
      Udi udi = null;
        if(!string.IsNullOrEmpty(hrStaffItem.photo) && Udi.TryParse(hrStaffItem.photo.ToString(), out udi)) {
        var mediaItem = udi.ToPublishedContent();    
    <figure>
      <img src="@GlobalHelpers.PhotoResize(@mediaItem.Url, 160, 198)" alt="@hrStaffItem.Name" />
    </figure>
    }
    }
    
  • Alex Skrypnyk 6182 posts 24284 karma points MVP 8x admin c-trib
    Aug 31, 2017 @ 15:12
    Alex Skrypnyk
    0

    Hi Tom

    Can you show all the code?

    Thanks,

    Alex

  • Tom 713 posts 954 karma points
    Sep 01, 2017 @ 01:11
    Tom
    0
     <umbraco:Macro runat="server" language="cshtml">
    

    @{ int staffCount = 0; foreach (var hrStaffItem in Model.Children) {

    @{ int photoId = 0; Udi udi = null; if(!string.IsNullOrEmpty(hrStaffItem.photo) && Udi.TryParse(hrStaffItem.photo.ToString(), out udi)) { var mediaItem = udi.ToPublishedContent();
    @hrStaffItem.Name
    } }

    @hrStaffItem.Name

    @hrStaffItem.description

    Email:
    @hrStaffItem.email
    Phone:
    @foreach (string phone in hrStaffItem.phone.ToString().Split('\n')) { @phone
    }
      </div>
    

    staffCount++; } }

  • 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