Media Gallery custom widget to show 2 latests images

rated by 0 users
This post has 0 verified answers | 2 Replies | 1 Follower

3 Posts
Points 30
SD45X posted on Thu, Apr 16 2009 1:52 PM

I need to write a custom widget (or whatever you want to call it) that shows the latest two uploaded images from user specific galleries. The problem is that I don't even know when do get started.

I'm assuming there is a way to get a specific gallery as a collection, order and then grab the first two?

Any help would be greatly appricated!

 

Thanx,

Peter

  • | Post Points: 20

All Replies

13 Posts
Points 245

I'm also trying to do something very similar. I was trying to fetch the images attached to a media gallery so I can iterate over them and make my own custom Lightbox gallery. I'm not exactly sure how to start or where the media info in stored in the DB. Are the media items in the "posts" table?

Any ideas are much appreciated.

  • | Post Points: 20
3 Posts
Points 30
SD45X replied on Fri, Apr 17 2009 6:30 PM
Suggested by Alex Crome

So I was able to figure this out for my specific case using the REST API. I pretty much get a collection for a specifc media gallery, I check if the items are published, I sort it by date, and then I just do getRange()

Something like:

using CommunityServer.WebServices.MediaGalleries;

MediaGalleriesService service = new MediaGalleriesService(ConfigurationManager.AppSettings["SiteURL"].ToString(), ConfigurationManager.AppSettings["SiteUser"].ToString(), ConfigurationManager.AppSettings["APIKey"].ToString());

MediaGallery media = service.GetMediaGallery(ConfigurationManager.AppSettings["MediaGalleryName"].ToString());

List<MediaGalleryPost> items = service.GetMediaGalleryPosts(media.Id);

items.Sort(*** Custom Compare Class ***);

items = items.FindAll(*** Custom IsPublished Method ***);

items = items.GetRange(0, 2);

And from here I have a cleaned collection that I can bind or loop through…

Hope this helps!

 

Peter

 

 

  • | Post Points: 5
Page 1 of 1 (3 items) | RSS
Powered by Community Server (Commercial Edition), by Telligent Systems

Copyright© 2008 Telligent Systems Inc. All rights reserved
CommunityServer.com  •  Telligent.com