# Album Plugin: captions/exif/mouseover # For info: 'album -plugin_info captions/exif/mouseover' # For usage: 'album -plugin_usage captions/exif/mouseover' use strict; use File::Copy; my $DESCRIPTION = << 'DESCRIPTION'; Add a mouseover window to images that displays photo EXIF info. DESCRIPTION # later.. my @KEY_ORDER = qw(); sub start_plugin { my ($opt) = @_; # Setup the options # album::add_option(1, 'embed', album::OPTION_BOOL, default=>1, # usage=>'Embed the sound in the page'); # Setup the hooks album::hook($opt, 'do_album', \&setup_script); album::hook($opt, 'modify_caption', \&modify_caption); return { author => 'David Madison', href => 'http://MarginalHacks.com/', version => '1.0', description => $DESCRIPTION, }; } # Come up with a legal 'id="name"' given a file. We may lose uniqueness # here if, for example we have two files: [ab;ba.jpg] and [ab!ba.jpg]. # Personally I'm not terribly bothered by this bug. # # From w3.org HTML 4.01 spec: # Legal ID and NAME tokens are of the format: [A-Za-z][A-Za-z0-9_:.-]* sub id { my ($file) = @_; # Remove illegal characters $file =~ s/[^a-z0-9_:\.-]/_/ig; # Make sure it starts with a letter $file =~ /^[a-z]/i ? $file : "Z$file"; } sub modify_caption { my ($opt, $data, $hookname, $dir, $pic, $cap) = @_; # Get the exif info ######################### my $pic_file = $data->{obj}{$pic}{full}{path} || "$dir/$pic"; my $exif = album::get_exif_info($opt,$data,$pic_file); return $cap unless $exif && ref $exif eq 'HASH'; my $id = id($pic); # Create the exif
| $key | $exif->{$key} | ELEMENT } $cap .= <