My photo gallery runs on Gallery2, which I like as a storage and display system but it’s not one of the most flexible photo gallery systems out there. Other than changing the themes and templates, it’s hard to customise the key functionality of it without using plugins – and if there isn’t one to do what you want, then you’re stuffed unless you can write your own.
In particular, what I miss in Gallery2, compared to some other galery systems, is the ability to easily show lists of albums in ways that don’t fit within the existing plugins and themes. The default front page of Gallery2 is just a set of thumbnails to albums, without any significant descriptive text or stats. So, I thought I’d do a little hackery and create my own.
My new gallery front page is completely standalone – it doesn’t hook into any of Gallery2’s internal routines – which has the advantage of being a lot more flexible and easy to write (once I’d got my head around the rather complex database structure). The disadvantage is that I’ll need to manually edit it if I ever change the main gallery theme or change the database structure, but that’s not really a major problem.
My four new features are: a list of the most popular albums (currently the top ten, but that’s simply a variable in the script), a list of the most recent albums (again, currently ten), a niftly little Ajaxy “people are currently viewing…” box and, on a separate page, a full text-based sitemap in tree format.
I think it looks better than the default front page (which is still there, it’s now the “thumbnail view” link from the new front page). It’s not complete yet – I want to add a few more things like “top photos this week” or similar – but it’s good enough for now.
Comments are welcome – I’d appreciate opinions on how to improve it, or anything that looks wrong to visitors.
You may have noticed that I’ve got Google Adsense adverts on my blog and photo gallery. Not that either of them is popular enough to generate significant income (in fact, it’s generally so insignificant that it’s practically invisible), but just on the off-chance that I suddenly become famous (or infamous) and loads of people start Googling me then I want to get something out of it! But it does give me some interesting insight into what goes on at the Adsense backend.
For those who aren’t familiar with it, the way Adsense works is that Google spiders your web page and indexes that so that it knows what words you’ve got on it. At the other end of the system, advertisers create ads and then bid on certain keywords that they want to trigger it. So, for example, travel agents might bid on words or phrases like “hotels” and “summer holiday”, ISPs might bid on terms like “broadband”, “VOIP” and “BTInternet sucks”, and ambulance-chasing lawyers might bid on “industrial accident”, “mesothelioma” and “asbestos cancer”. If your page matches a keyword that’s being bid on, then that advert gets shown on your site.
Anyway, the thing about the photo gallery is that it’s primarily images – which don’t affect Adense as it’s entirely text based. And most of the text on the gallery is common to all pages – things like the header and sidebar – so the only difference between individual pages is the title and caption of the image and gallery. So if I get different adverts on different galleries, then it has to be the album and image titles themselves that are the relevent keywords. And, in many cases, the captions are still the filename (something like “DSCF01234”), which isn’t particularly interesting.
In most cases, the results are what you’d expect. For example, the photos of Barcelona get adverts for travel agents. The photos of the U2 gigs get ticket agencies. The photos of the cats get adverts for pet food suppliers. Rather amusingly, the food photos get adverts for, inter alia, diet programmes! But the one that intrigues me is that photos of an event run by a former employer carry adverts for a different organisation, working in the same field but in many respects a direct rival. And this is one where the image captions are just filenames, and the category name carries other adverts in different albums. Plus, thse adverts don’t appear anywhere else on the site. So the only thing that can be generating those particular adverts on those pages is the name of my former employer, as that’s the only factor which is present only there and nowhere else. Which means that the rival organisation is actually bidding on that name when placing adverts. They want you to see adverts for them when looking at websites talking about my former employer.
That’s perfectly legitimate, but it still seems a tad sneaky. It’s the equivalent of Barclays bidding on “Lloyds” as a keyword, or Microsoft bidding on “Linux”. And it makes me wonder how much of this is going on in the Adsense world – how many adverts are deliberately placed alongside copy relating to a rival. Hmmm.
Emma has been pestering me to add some more recent photos to the gallery, so I’ve finally dug out the circular tuits and added albums from a day out at Trentham Gardens, our summer holiday in Scotland, this year’s Greenbelt and a random selection of autumn-themed photos.
As well as adding stuff to the gallery, I’ve also been playing around with a couple of additions to the code. One of the weaknesses of Gallery2, in my opinion, is that it doesn’t store any meaningful visitor stats – all it records is an overall total of views for items and albums. So there’s no way to see if an item is becoming more or less popular over time, or have any way of making a meaningful comparison between newer and older items. So I’ve hacked the code a bit to make it store a line-by-line record of views, meaning that I can then extract them by date to get a rolling total or see trends. It also means I can get to see who is looking at what, and with what, since it also records IP addresses and user-agents.
The other thing I wanted, but couldn’t find in any of the available plugins, is a Flickr-like photostream widget for Gallery2. So, again, I’ve written my own. Or, to be more precise, I’ve written a script that takes my own stats data and then generates thumbnail links from it that are then formatted into a photostream block. It’s very rough and ready – nothing more than a single page incorporated into WordPress by means of an iframe – and I may well improve it in the future (although, then again, I may not), but it works well enough for now. Those of you reading this article on the blog itself (as opposed to planet.uknot or Facebook) will see the widget at the top of the right-hand column on the front page. Comments are welcome. But no, I’m not releasing the code until it’s undergone a considerable amount of tidying up!
I’ve gone through my back catalogue of photos, and added a bunch of them to the photo gallery.