Photoblog update

Written by: | Posted on:

Right, I've ended up adding a Photoblog category to my blog. I'm sure someone will hold the definition against me and scream some bad language in my face, but hey, this works for me.

The four options as I saw it was [keep using][1] Gallery as a Photoblog, install a separate blog for Photoblogging, tweak my WordPress template or make a WordPress plugin for Photoblog posts. The first two could be "integrated" through building a little script that would take the different RSS feeds and make them into one. The last one would probably be the nicest as all about the post would go into the post text in the database. Only problem is: my PHP server doesn't support exif and as I've just moved my server I couldn't really be bothered to redo the PHP installation right now.

So I went for option three: tweak my template. This consisted of checking when a post was from the Photoblog category and then present it like I want my photoblog entries presented, which for now is with SOME exif-data (my Canon EOS 20D gives by far too much uninteresting data, so I took only out what I thought to be interesting enough to share. If you want the rest, grab the picture and extract them yourself :-) ).

graphics/exiftags from FreeBSD's ports collection was installed, index.php and archive.php got a little extra with:

< ?php if(the_category_ID(false)==13) { include "photoblog.php"; } else { ?>

and photoblog.php was basically:

$content=get_the_content();
$src=strpos($content, "src");
$start=strpos($content, """, $src);
$end=strpos($content, """, $start+1);
$src=substr($content, $start+1, $end-$start-1);
$src=str_replace(".sized", "", $src);
echo $content;

$sha1 = sha1($src);
$cache = ABSPATH . "wp-content/cache/".$sha1;
if(file_exists($cache)) { echo "

"; include($cache); echo "
"; }
else {
exec("/usr/bin/fetch -q -o /tmp/".$sha1." $src");
exec("/usr/local/bin/exiftags < /tmp/".$sha1." > $cache.tmp");
exec("/bin/rm /tmp/".$sha1);
exec("/usr/bin/grep Created $cache.tmp >> $cache");
exec("/usr/bin/grep Exposure $cache.tmp | /usr/bin/grep -v Mode >> $cache");
exec("/usr/bin/grep ISO $cache.tmp >> $cache");
exec("/usr/bin/grep Focal $cache.tmp >> $cache");
exec("/usr/bin/grep Lens $cache.tmp >> $cache");
exec("/bin/rm $cache.tmp");
echo "
"; include($cache); echo "
";
}
?>

I'll add some presentation later for the more minimalistic approach. But right now, I think it looks quite good. Of course, an option five: auto-blog my entries to Gallery's Photoblog gallery would've been even better, but for now this is all right.

[1]: /photos/Photoblog

Photoblog

Written by: | Posted on:

My first attempt isn't really a photo blog as much as it is Gallery with its own category. See it here and subscribe to the RSS if you like. Today's entry:

Yesterday's entry:

Image Image

Father, husband, software developer, musician and photographer.


Get to know what I'm up to

© 2020 Niklas Saers Contact Me