Copied to clipboard

Flag this post as spam?

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


  • k 255 posts 652 karma points
    Jul 13, 2017 @ 10:32
    k
    0

    Media picker 7.6.3

    Hello,

    I am using media picker in umbraco 7.6.3.

    And I am using the code

        if(CurrentPage.HasValue("pickBannerFolderFromMedia"))
            {       
                 var sliders = Umbraco.Media(CurrentPage.pickBannerFolderFromMedia);
    foreach(var slider in sliders.Children)
    

    But the above is not working.

    Thanks for helping.

    kusum

  • emma burstow 43 posts 244 karma points MVP 3x hq c-trib
    Jul 13, 2017 @ 10:50
    emma burstow
    0

    Hi Kusum,

    You need to use something like this

    Var sliders = Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("sliders");
    

    where "sliders" is the property name assigned to the media picker. Then your foreach loop should work by saying

           foreach(var slide in sliders)
             {
                <img src="@slide.Url"/>
              }
    

    Does that help?

    Emma

  • k 255 posts 652 karma points
    Jul 13, 2017 @ 11:07
    k
    0

    Hello Emma,

    No its not working.

    Actually when I do :

     var sliders = CurrentPage.pickBannerFolderFromMedia;
    

    I get the id of the media folder. But then I cannot do a foreach to get the images in the folder.

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Jul 13, 2017 @ 11:44
    Alex Skrypnyk
    1

    Hi Kusum and Emma

    It looks like you don't have property value converter on your project. Try this code:

    var mediaFolder = Umbraco.TypedMedia(Umbraco.AssignedContentItem.GetPropertyValue<int>("pickBannerFolderFromMedia"));
    
    foreach (var slider in mediaFolder.Children)
    {
    
    }
    

    Thanks,

    Alex

  • k 255 posts 652 karma points
    Jul 13, 2017 @ 12:22
    k
    0

    Hello Alex,

    Thanks for your reply . It is working.

     <!-- Enables value converters for all built in property editors so that they return strongly typed object, recommended for use with Models Builder -->
    <EnablePropertyValueConverters>true</EnablePropertyValueConverters>
    

    The property vlue converter is set to true. Do I need to do something else to activate the property value converter please ?

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Jul 13, 2017 @ 12:22
    Alex Skrypnyk
    0
    <EnablePropertyValueConverters>true</EnablePropertyValueConverters>
    

    This property is enough for enabling it.

    Thanks,

    Alex

  • k 255 posts 652 karma points
    Jul 13, 2017 @ 12:31
    k
    0

    Ok thanks,

    And if I want to get the value of a field in Media

    Previouslyt I used to do @slider.textboxOne and it worked. But now it's not working.

    Is there any documentation to which I can refer ?

    Regards,

    kusum

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Jul 13, 2017 @ 12:32
  • k 255 posts 652 karma points
    Jul 13, 2017 @ 12:45
    k
    0

    Sorry to bother you again Alex :

    I have tried the below on image cropping

    @Umbraco.TypedMedia(@slider.id).GetCropUrl("uploadBanner", "large")
    

    But not working. I am sorry I am completely lost with this 7.6 :(

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Jul 13, 2017 @ 13:36
    Alex Skrypnyk
    100

    It works for me:

    var mediaFolder = Umbraco.TypedMedia(Umbraco.AssignedContentItem.GetPropertyValue<int>("pickBannerFolderFromMedia"));
    
    foreach (var slider in mediaFolder.Children)
    {
        @Umbraco.TypedMedia(slider.Id).GetCropUrl("uploadBanner", "large")
    }
    
  • k 255 posts 652 karma points
    Jul 24, 2017 @ 11:37
    k
    0

    Hello Alex,

    Please find below the error I am getting : enter image description here

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Jul 24, 2017 @ 11:42
    Alex Skrypnyk
    0

    Hello Kusum

    "mediaFolder" var is null in your case, can you debug and fix it?

    Thanks,

    Alex

  • 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