Copied to clipboard

Flag this post as spam?

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


  • Karen Worth 47 posts 140 karma points
    Feb 16, 2017 @ 15:06
    Karen Worth
    0

    How to retrieve image properties from multiple images uploaded via media picker

    I can display all the images nicely, using a partial view macro which displays the images beautifully, but I have added a 'link' property to the image settings so the team user can specify where they want the image linked to, and I then need to be able to pull this out for each image in order to surround the @hpItem.Url (src ref) and make each image clickable to direct to another page. I hope that is clear. This would be so easy in .NET! something like @hpItem.link ? or is that too obvious (it doesn't work anyway).

    Currently I have the code (which displays perfectly):

    @if (CurrentPage.HasValue("rptImg")) { var rptImgImagesList = CurrentPage.rptImg.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);

    var rptImgImagesCollection = Umbraco.Media(rptImgImagesList); foreach (var hpItem in rptImgImagesCollection) {

    <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3" >
        <div class="imgc img-responsive">
                 <img src="@hpItem.Url" />
        </div>
    </div>
    
    }
    

    }

  • Nigel Wilson 945 posts 2077 karma points
    Feb 16, 2017 @ 21:56
    Nigel Wilson
    100

    Hi Karen

    Untested, but I think the following should give you the value:

    hpItem.GetPropertyValue("link")
    

    Hope this helps

    Cheers, Nigel

  • Karen Worth 47 posts 140 karma points
    Feb 17, 2017 @ 08:01
    Karen Worth
    0

    thanks Nigel, I thought I had already tried that, but apparently not. I knew it would be something that simple. Obviously my next step is to swat up on Razor coding! Much appreciated!

Please Sign in or register to post replies

Write your reply to:

Draft