New Gallery Server Pro Recent Photos View

I was looking for an opportunity to dig into Roger Martin’s rockin’ Gallery Server Pro source code for a while now, and creating a Recent Photos View for Sueetie was my big chance.  Here’s the new Recent Photos View of my personal Photo Gallery so you’ll know what I’m talking about.  


Below is what it looked like before with Gallery Server Pro’s default home page view.

I wanted to go to my Photo Gallery and immediately see what’s new, so I designed Recent Photos to serve as the gallery home page.  The out-of-the-box album view is efficient, but it’s pretty static and rarely displays any new content without first digging into the albums. 

In addition to wanting to see what’s new with the Recent Photos view, it was also important to be able to specify additional gallery home page views in Sueetie’s future, like by document type, or by albums listed vertically with additional descriptions and information.

As you probably know, site-wide settings for a Sueetie community site are located in the root Sueetie.config file.  For our Recent Photos view, we’re using Sueetie.config to set the "recentphotos" page as the media gallery home page view.


StartPage (default = album)
    Specifies which page to use as Media Gallery start page 
    Three options:
        1. album – Default display of Gallery Server Pro
        2. recentphotos – All photos in gallery displayed in reverse chronological order
        3. folders – Display of media albums with additional Sueetie data,
            arranged by media type

RecentPhotoCount (default = 160 @ 16 photos/page)
    Number of photos to retrieve for recent photos to prevent retrieving entire media gallery.

    RecentPhotoCount="160" />

Gallery Server Pro is designed as a User Control to make it easy to drop it into an existing site.  The base GalleryPage.cs class loads the appropriate page based on various criteria, so we added a Sueetie Configuration option when loading the home page.

string sueetiePage = SueetieConfiguration.Get().Media.StartPage;
page = (PageId)System.Enum.Parse(typeof(PageId), sueetiePage, true);

"PageId" is an enumerator to which we added a "RecentPhotos" value with the result that instead of loading the default "album.ascx" page, we’re loading "recentphotos.ascx."

The approach I took was to create a new "album" for Recent Photos with the AlbumID of -1.  That way only a few changes were required in Gallery Server Pro, allowing us to leverage all Gallery Server Pro security rules and functionality. 

I modified the Gallery Server Pro data provider method that populated the album contents along with a new stored procedure to handle both recent photos and normal album media object retrieval.

The above data provider change was one of only two touches to the Gallery Server Pro source outside of the Web project.  The other was to sort the Recent Photos collection by DateCreated, with most recent first.

One remaining update was required in the Web project to generate the correct thumbnail url.  Gallery Server Pro Media objects are stored by album name, so we needed to obtain the original GalleryObject parent information when generating the url.  We do that by loading a MediaObjectInstance() for each photo on the first trip, which isn’t a performance hit as you might suspect since the collection is then cached.

Now with Recent Photos logic in place we’re able to do something else with Gallery Server Pro that I’ve been wanting to do.  That’s right, the next new Sueetie feature will be a control to display recent photos outside of Gallery Server Pro.  Ehhhh, there goes the surprise!

Article written by

A long time developer, I was an early adopter of Linux in the mid-90's for a few years until I entered corporate environments and worked with Microsoft technologies like ASP, then .NET. In 2008 I released Sueetie, an Online Community Platform built in .NET. In late 2012 I returned to my Linux roots and locked in on Java development. Much of my work is available on GitHub.