Copied to clipboard

Flag this post as spam?

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


  • Mark Evans 86 posts 116 karma points
    Sep 03, 2014 @ 09:54
    Mark Evans
    0

    identifying media image type

    i have a basic image carousel that is looping through images in a folder (within media) , however now that sub folders are added the carousel breaks and i think its bwecause the folders are seen as children of the folder and being treated as images (so cant resolve url)

    how do i check for an image type (to stop folders being rendered)?

    @foreach (var mediaItem in myMediaFolder.Children)              

                {

                    <li style="margin-right:10px;"><img src="@mediaItem.Url" alt="@mediaItem.Name" width="100" height="70"></li>

                } 

  • Sören Deger 726 posts 2833 karma points c-trib
    Sep 03, 2014 @ 10:52
    Sören Deger
    0

    Hi Mark,

    you can exlude the folders with an where-statement like this :
     

    foreach (var mediaItem in myMediaFolder.Children.Where("NodeTypeAlias==\"Folder\""))
    {
    ....


    Or you can check the NodeTypeAlias with an if-statement in the foreach-loop.


    Sören

  • Jeavon Leopold 3008 posts 13221 karma points MVP 7x admin c-trib
    Sep 03, 2014 @ 13:01
    Jeavon Leopold
    1

    @Soren, I think Mark needs that in reverse :-)

    Either:

    foreach (var mediaItem in myMediaFolder.Children.Where("NodeTypeAlias!=\"Folder\""))
    {
    ....
    } 
    

    Or

    foreach (var mediaItem in myMediaFolder.Children.Where("NodeTypeAlias==\"Image\""))
    {
    ....
    } 
    
  • Sören Deger 726 posts 2833 karma points c-trib
    Sep 03, 2014 @ 13:04
    Sören Deger
    0

    Hi Jeavon,

    of course, you're right :-)

  • Mark Evans 86 posts 116 karma points
    Sep 03, 2014 @ 17:17
    Mark Evans
    0

    thats great thanks

  • 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