# Blosxom Plugin: add_exif # Author: Khan Klatt (http://www.khan.org) # Version: 0.1 (20080811) # Plugin Homepage: # http://www.khan.org/add_exif # License: GPL # Documentation: Please see the end of this file or use perldoc add_exif package add_exif; # --- Configuration --- my $jhead_binary = '/usr/local/bin/jhead'; # Where is jhead? my $prefix = '/home/username/public_html'; # Where are your images? sub start { 1; } sub rewriteIMG { my ($img) = @_; $img =~ s#\.\.##g; # Strip any .. paths $img =~ s#\[img:(.+)\]#$1#ie; my $tag .= '
'; $tag .= "
"; $tag .= `$jhead_binary $prefix/$img`; $tag .= '
'; $tag =~ s#$prefix/##; # Strip the prefix from public view return $tag; } sub story { my($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_; # Rewrite any [img:...] pseudo-tag in the post body $$body_ref =~ s/(\[img:[^\]]+\])/rewriteIMG($1)/sgie; 1; } 1; __END__ =head1 NAME Blosxom Plugin: add_exif =head1 SYNOPSIS This extension adds an exif element for images. Use the pseudo tag [img:PATH] syntax. This plugin will rewrite PATH as as well as adding a div and a span for exif data. You can format the EXIF div using the CSS class "exif" and "showexif" for advanced formatting options. See the "SAMPLE CSS" section below. Exif data is obtained using the "jhead" utility which is available here: http://www.sentex.net/~mwandel/jhead/ Clearly, this script exposes jhead to the blog author's whims. Since it's assumed that the blog author has access to the filesystem, the fact that the author can refer to any $prefix/$img combination (including ../.. style paths) isn't considered a bug. Use this wisely, ideally constrained to images that you normally serve from public_html. =head1 SAMPLE CSS .exif { display:none; } .showexif:hover { position: relative; } .showxif span { display: none; } .showexif:hover span { display: block; position: absolute; bottom: 20px; left: 20px; font-family: "Andale Mono", Courier, monotype; background: #f0f0f0; border: 1px dotted #c0c0c0; opacity: 0.5; white-space: pre; } =head1 VERSION 0.1 =head1 AUTHOR Khan Klatt (http://www.khan.org/) =head1 LICENSE GPL =cut