Click here to Skip to main content
11,431,011 members (73,282 online)
Click here to Skip to main content
Technical Blog

Tagged as

Modify Nextgen Gallery to Extract Picasa’s Caption

, 18 Sep 2013 CPOL
Rate this:
Please Sign up or sign in to 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:

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:

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

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)

Share

About the Author

JIN Weijie
Software Developer (Senior) Honeywell
China China
ASTreeView, the best FREE treeview control for ASP.NET.
Follow on   Twitter

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150428.2 | Last Updated 18 Sep 2013
Article Copyright 2013 by JIN Weijie
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid