Copied to clipboard

Flag this post as spam?

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


  • René 327 posts 852 karma points
    Jul 05, 2012 @ 23:20
    René
    0

    Get Media from 2 folders

    Hi

    Umbraco ver 4.7.2

     

    I try to create a gallery with pictures of two folders, one for thumbsnails and one for the big pictures

    I'm stuck and I hope there is someone who can give a hint in the right direction

     

    @using umbraco.MacroEngines
    @inherits umbraco.MacroEngines.DynamicNodeContext

    @{
       if (Model.HasValue("photos"&Model.HasValue("thumb"))
       {
        var MediaFolder Library.MediaById(Model.photos);
        var ThumbFolder Library.MediaById(Model.thumb);
        foreach (var item in Model.Children)
            {
             <href={@ThumbFolder.umbracoFile}>
    <img data-big="@MediaFolder.umbracoFile" src="@MediaFolder.umbracoFile" alt="" ></a>
             
            }    
        }

     }

    Tanks in advance

    René

  • Douglas Ludlow 210 posts 366 karma points
    Jul 06, 2012 @ 00:03
    Douglas Ludlow
    0

    Hey René, I'd be happy to help only I'm a little confused what you're trying to do. Let me see if I get this right: You have two folders in the Media section, one includes the photos, and the other includes the thumbnails? How are you planning to match those up? Unless you really want to have the user create their own thumbnails, I'd suggest using ImageGen to auto-generate the thumbnails. In which case you'd do something like this:

    @using umbraco.MacroEngines
    @inheritsDynamicNodeContext
    @if(Model.HasValue("photos"))
    {
       
    var folder =Library.MediaById(Model.photos);
       
    foreach(var child in folder.Children)
       
    {
           
    <a href="@child.umbracoFile">
               
    <img src="/ImageGen.ashx?image=@(media.umbracoFile)&height=100" alt=""/>
           
    </a>
       
    }
    }
  • René 327 posts 852 karma points
    Jul 06, 2012 @ 08:26
    René
    0

    HI Douglas

    I understand you were confused, i was stuckd in a solution that was not working, and i my self were a bit confused.

    Tanks for your help, works great. 

    Here is the code i used (one small thing changed medie changed to child)

    @using umbraco.MacroEngines
    @inherits DynamicNodeContext

    @if(Model.HasValue("photos"))
    {
        var folder =Library.MediaById(Model.photos);
        foreach(var child in folder.Children)
        {
            <href="@child.umbracoFile">
                <img src="/ImageGen.ashx?image=@(child.umbracoFile)&height=100" alt=""/>
            </a>
        }
    }

    Tanks

Please Sign in or register to post replies

Write your reply to:

Draft