forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 miscellaneous => Topic started by: jaus on May 01, 2008, 02:56:45 am

Title: [Solved]: removing characters from keywords
Post by: jaus on May 01, 2008, 02:56:45 am
The IPTC captions for my images include phrases in parenthesis, for example (alpha beta), or just (beta).  When the caption is added to the keywords these phrases come out as  '(alpha', 'beta)', or in the second case '(beta)'.

Is there a fairly simple mod that I can do that will remove the parenthesis (and perhaps other characters) from the keyword when the images are imported ( I don't really know how this works, I am assuming they are created at import).  I do not want to remove them from the captions, and there will be too many to remove manually.

Thanks,
Joe
Title: Re: removing characters from keywords
Post by: Nibbler on May 01, 2008, 10:35:48 am
include/picmgmt.inc.php

Code: [Select]
        if ($CONFIG['read_iptc_data']) {
           $iptc = get_IPTC($image);
           if (is_array($iptc) && !$title && !$caption && !$keywords) {  //if any of those 3 are filled out we don't want to override them, they may be blank on purpose.
               $title = (isset($iptc['Title'])) ? $iptc['Title'] : $title;
               $caption = (isset($iptc['Caption'])) ? $iptc['Caption'] : $caption;
               $keywords = (isset($iptc['Keywords'])) ? implode(' ',$iptc['Keywords']) : $keywords;
           }
        }

Use str_replace() to strip out the parentheses.
Title: Re: removing characters from keywords
Post by: jaus on May 02, 2008, 12:10:14 pm
got it working, thanks.
Title: Re: [Solved]: removing characters from keywords
Post by: jaus on October 13, 2008, 12:13:30 am
I had this working, but have not used coppermine for a while.  I recently started working with coppermine again and now this mod doesn't work anymore.   

In include/picmgmt.inc.php I changed this:

Code: [Select]
        if ($CONFIG['read_iptc_data']) {
           $iptc = get_IPTC($image);
           if (is_array($iptc) && !$title && !$caption && !$keywords) {  //if any of those 3 are filled out we don't want to override them, they may be blank on purpose.
               $title = (isset($iptc['Title'])) ? $iptc['Title'] : $title;
               $caption = (isset($iptc['Caption'])) ? $iptc['Caption'] : $caption;
               $keywords = (isset($iptc['Keywords'])) ? implode(' ',$iptc['Keywords']) : $keywords;
           }
        }

TO THIS:

Code: [Select]
        if ($CONFIG['read_iptc_data']) {
           $iptc = get_IPTC($image);
           if (is_array($iptc) && !$title && !$caption && !$keywords) {  //if any of those 3 are filled out we don't want to override them, they may be blank on purpose.
               $title = (isset($iptc['Title'])) ? $iptc['Title'] : $title;
               $caption = (isset($iptc['Caption'])) ? $iptc['Caption'] : $caption;
               $keywords = (isset($iptc['Keywords'])) ? implode(' ',$iptc['Keywords']) : $keywords;
           $parens = array("(" , ")");
               $keywords = str_replace($parens , "" , $keywords);           }
        }


It was doing what I wanted (removing parenthesis from keywords) now it doesn't.  I don't see what the problem is.  The only change I have made is upgrading to 1.4.19

What could have changed?

Thanks,
Joe.