I wanted to have a flickr-like badge: I mean a way to have the last 5 pictures that I added to my Coppermine gallery be shown on my blog sidebar.
I especially wanted:
* to display public pictures only,
* to be able to have some pictures not to appear in the badge.
I’ve been looking for an existing WP plugin, but couldn’t get to find any, so i decided to start learning a bit of php to do-it-myself!
I’ve accomplished the first point by using the album visibility field: if visibility=0, it’s a public album.
Then, to discard some pictures from appearing in the badge, i use the keywords. I’ll select only pictures which do not have the “nobadge” keyword. (I’ve defined this special keyword arbitrarily.)
The resulting MySQL query I use is:
SELECT pid,filepath,filename,p.title
FROM cpg_pictures p, cpg_albums a
WHERE a.aid=p.aid
AND keywords NOT LIKE "%nobadge%"
AND a.visibility=0
ORDER BY pid DESC LIMIT 5;
Doing the remaining work was rather easy… The resulting “badge” appears in the sidebar!

0 Response to “Coppermine badge”