Click here to Skip to main content
15,896,545 members
Articles / All Topics
Technical Blog

Modify Nextgen Gallery to Extract Picasa’s Caption

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
18 Sep 2013CPOL 5.8K  
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:

nextgen_gallery_pre

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:

PHP
$alttext = empty( $meta['title'] ) ? $image->alttext : $meta['title'];

// get the caption / description field
$description = empty( $meta['caption'] ) ? $image->description : $meta['caption'];

with:

PHP
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:

PHP
$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:

PHP
if ($this->iptc_data[$key])
    $meta[$value] = trim(utf8_encode(implode(", ", $this->iptc_data[$key])));

with:

PHP
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:

nextgen_gallery_result

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.)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Honeywell
China China
ASTreeView, the best FREE treeview control for ASP.NET.

Comments and Discussions

 
-- There are no messages in this forum --