Fix NextGen Gallery IPTC Encoding Error in Chinese

by Weijie JIN on

NextGen Gallery is a great gallery plugin for wordpress. I am using it for my blog.

I found a problem that if the IPTC information is in Chinese, it cannot import properly import as meta data.

After searching and searching, finally I fixed the issue by modifying the /wp-content/plugins/nextgen-gallery/lib/meta.php file in get_IPTC function:

Original code:

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

Modify to:

foreach ($iptcTags as $key => $value) {
    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])));
    }
}

That’s it. Smile

  • Ulrike Häßler

    Two years later this tipp helped me to get IPTC 2#120 correct into nextgen — for german Umlaute — after half a day of investigation … thank you

    Ulrike
    Great photos by the way!

Previous post:

Next post: