Copied to clipboard

Flag this post as spam?

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


  • Nhi A Sy 4 posts 74 karma points
    Mar 16, 2021 @ 09:41
    Nhi A Sy
    0

    Get top x last upload in Media

    Hey

    It's there away to get top x last upload media in a specific folder + subfolder?

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 10x admin c-trib
    Mar 17, 2021 @ 07:43
    Dave Woestenborghs
    0

    Hi,

    Do you want to show this in the backoffice or on your website ?

    Dave

  • Nhi A Sy 4 posts 74 karma points
    Mar 17, 2021 @ 07:53
    Nhi A Sy
    0

    Hi,

    No I want show it on frontend to the customer

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 10x admin c-trib
    Mar 17, 2021 @ 08:09
    Dave Woestenborghs
    0

    Hi

    This code will show the last x number of images in a folder.

    @{
        var folder = Umbraco.Media(1215);
    
        var lastUpdatedImages = folder.DescendantsOfType("image").OrderByDescending(x => x.CreateDate).Take(4).ToList();
    }
    
    @foreach (var image in lastUpdatedImages)
    {
        <img src="@Url.GetCropUrl(image, 100,100)" />
    }
    

    This should be a good starting point.

    Dave

  • Nhi A Sy 4 posts 74 karma points
    Mar 17, 2021 @ 08:28
    Nhi A Sy
    0

    That is so good, thank you very much Dave :-)

  • 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