Copied to clipboard

Flag this post as spam?

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


  • Jeremy Holland 13 posts 33 karma points
    Jul 28, 2011 @ 02:54
    Jeremy Holland
    0

    Get items in two different media folders

    I'm trying to generate a photo album using the jQuery plug-in Galleriffic. I've got my images and thumbnails saved in their own directories in a distinct gallery folder. 

    --GalleryRoot

    ----slides

    ----thumbs

    On the document type I have a Media Picker that points to the parent folder of the slides and thumbs folders, called GalleryRoot in the example above.

    I'm very frustrated with getting the umbracoFile (image path) property for each image from both of the subfolders

    The final HTML that I'm trying to generate should be a repeating series of <li> elements like this:

    <li>
      <a class="thumb" href="mediaPath/slides/image.jpg" title="Image Title">
      <img src="mediaPath/thumbs/image.jpg" alt="Alt Text" />
      </a>
      <div class="caption">
      <div class="image-title">Image Title</div>
        <div class="image-desc">
        <strong>Image description</strong>
        </div>
      </div>
    </li>

    I've been trying to get to the umbracoFile property like this since I don't know how to debug live:

    var children = uQuery.GetMedia(Model.imageLibrary).Children;
    var galleryName = uQuery.GetMedia(Model.imageLibrary).Text;
    var slides = children[0].Children;
    var thumbs = children[1].Children;
    for(int x=0;x<slides.Length;x++)
        {
          <p>@slides[x].Id</p>
          Media media = @uQuery.GetMedia(@slides[x].Id);
          <p>@media.umbracoFile</p>
        }

    The problem is that I get an error:

    error CS1061: 'umbraco.cms.businesslogic.media.Media' does not contain a definition for 'umbracoFile'

    I'm very new to this Razor syntax and my understanding of the Umbraco object model is limited so I'm probably missing something easy here. I would appreciate some help or direction in how to get to the umbracoFile property and the image URL. Thanks in advance for the help!

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 28, 2011 @ 08:20
    Dirk De Grave
    0

    Jeremy,

    Media media = @uQuery.GetMedia(@slides[x].Id);

    returns a Media object and the umbracoFile property can be retrieved using media.GetProperty("umbracoFile").Value.ToString()

    If you want to use the Razor syntax, you'd need

    var media = Model.MediaById(id);

    which will return a DynamicMedia object, allowing to use the .umbracoFile notation to retrieve the property.

     

    Hope this helps.

    Regards,

    /Dirk

     

     

  • Jeremy Holland 13 posts 33 karma points
    Jul 28, 2011 @ 16:47
    Jeremy Holland
    0

    Thanks so much, Dirk. Your suggestions were just what I was looking for. I would vote your answer as helpful, but I don't have enough karma yet.

Please Sign in or register to post replies

Write your reply to:

Draft