Copied to clipboard

Flag this post as spam?

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


  • René Andersen 238 posts 684 karma points
    May 04, 2015 @ 15:34
    René Andersen
    0

    Show images with content picker or MNTP

    Hi,

    I want to use the content picker or the MNTP to choose a item with several images which is picked using the multiple media picker. I can't figure out how to show the images.

    I use this code which renders out the folder where the images are located. (Remember the images is not made as children to this folder, but picked with the multiple media picker.)

    @{
    if (CurrentPage.HasValue("contentPicker")){
    var node = Umbraco.Content(CurrentPage.contentPicker);
    <a href="@node.Url">@node.Name</a>
    }
    }

    Thanks in advance!

    // René

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    May 04, 2015 @ 20:09
    Dennis Aaen
    100

    Hi René

    If I understand you´re setup correct then you have a node where you have a multiple media picker, where you pick different images. And then on another node you are choosen the item, by a content picker. If so I think something like this should work for you.

    @{
      if (CurrentPage.HasValue("contentPicker")){
        var node = Umbraco.Content(CurrentPage.contentPicker);
      
          if (node.HasValue("multipleMediaPicker")){
                var imagesList = node.multipleMediaPicker.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                var imagesCollection = Umbraco.Media(imagesList);
           
                foreach (var image in imagesCollection)
                {
                    <img src="@image.Url" />
                }
        }
      }
    }

    Remember to change the aliases so it match your case. Try too see this documentation about using the multiple media picker https://our.umbraco.org/documentation/Using-Umbraco/Backoffice-Overview/Property-Editors/Built-in-Property-Editors-v7/Media-Picker

    Hope this helps,

    /Dennis

  • René Andersen 238 posts 684 karma points
    May 15, 2015 @ 14:40
    René Andersen
    0

    Hi Dennis,

    I know that it is a little late to answer. :-)

    Once again you solved my problem.

    Thanks!

    // René

Please Sign in or register to post replies

Write your reply to:

Draft