[Solved]: removing characters from keywords [Solved]: removing characters from keywords
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

[Solved]: removing characters from keywords

Started by jaus, May 01, 2008, 02:56:45 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jaus

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

Nibbler

include/picmgmt.inc.php


        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.

jaus


jaus

#3
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:

        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:

        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.