Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: [Solved]: removing characters from keywords  (Read 2113 times)

0 Members and 1 Guest are viewing this topic.

jaus

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 84
[Solved]: removing characters from keywords
« 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
« Last Edit: May 02, 2008, 12:26:44 pm by Hein Traag »
Logged

Nibbler

  • Guest
Re: removing characters from keywords
« Reply #1 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.
Logged

jaus

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 84
Re: removing characters from keywords
« Reply #2 on: May 02, 2008, 12:10:14 pm »

got it working, thanks.
Logged

jaus

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 84
Re: [Solved]: removing characters from keywords
« Reply #3 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.
« Last Edit: October 13, 2008, 08:02:16 am by Joachim Müller »
Logged
Pages: [1]   Go Up
 

Page created in 0.018 seconds with 20 queries.