Modify Nextgen Gallery to Extract Picasa’s Caption





0/5 (0 vote)
How to modify Nextgen gallery to extract Picasa's caption
I use Picasa to manage my photos locally and Nextgen gallery (a Wordpress plugin) as my online photo albums.
And in Picasa, captions can be added to photo’s meta tags, like this:
When uploaded to Nextgen gallery, I would like to have this caption be added to the photo’s title and description. So I modified the Nextgen gallery to support this.
The modifications in Nextgen gallery plugin:
1. Modify admin/function.php:
At line number 661, replace:
$alttext = empty( $meta['title'] ) ? $image->alttext : $meta['title'];
// get the caption / description field
$description = empty( $meta['caption'] ) ? $image->description : $meta['caption'];
with:
if (!$alttext = $meta['title'])
$alttext = ($meta['keywords'] . " " . $meta['camera']);
// get the caption / description field
if (!$description = $meta['caption'])
$description = ($meta['exif_desc'] . " " . $meta['keywords'] );
else
$description = ( $description . ' [EXIF :: ' . $meta['exif_desc'] . ']' );
if( trim($alttext) == "" || trim($alttext) == "Exif_JPEG_PICTURE" ){
if( $meta['caption'] )
$alttext = $meta['caption'];
else
$alttext = $description;
}
At line 734, add:
$meta['exif_desc'] = ($pdata->get_META('camera') . " :: " .
$pdata->get_META('focal_length') . " :: " . $pdata->get_META('shutter_speed') .
" :: " . $pdata->get_META('aperture') . " ::
ISO " . $pdata->get_META('iso') . " :: " .
$pdata->get_META('created_timestamp'));
2. Modify lib/meta.php
At line 237, replace:
if ($this->iptc_data[$key])
$meta[$value] = trim(utf8_encode(implode(", ", $this->iptc_data[$key])));
with:
if($this->iptc_data[$key] && $key == "2#120"){
$meta[$value] = mb_convert_encoding(implode
(", ", $this->iptc_data[$key]), 'UTF-8', 'gb2312');
}
else if($this->iptc_data[$key]){
$meta[$value] = trim(utf8_encode(implode(", ", $this->iptc_data[$key])));
}
And the final result looks like:
You may download the modified package here. (In the package, there are also some modifications in the UI, you may compare the package with the original one to see the difference.)