From 9f037e7cea37aafd562fa494afd9a289c60a5855 Mon Sep 17 00:00:00 2001 From: plegall Date: Sat, 20 Nov 2004 18:07:51 +0000 Subject: takes not only the first keyword in IPTC field 2#025 git-svn-id: http://piwigo.org/svn/trunk@611 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions_metadata.inc.php | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) (limited to 'include/functions_metadata.inc.php') diff --git a/include/functions_metadata.inc.php b/include/functions_metadata.inc.php index aed7d1ff2..930c90979 100644 --- a/include/functions_metadata.inc.php +++ b/include/functions_metadata.inc.php @@ -50,16 +50,18 @@ function get_iptc_data($filename, $map) $rmap = array_flip($map); foreach (array_keys($rmap) as $iptc_key) { - if (isset($iptc[$iptc_key][0]) and $value = $iptc[$iptc_key][0]) + if (isset($iptc[$iptc_key][0])) { - // strip leading zeros (weird Kodak Scanner software) - while ($value[0] == chr(0)) + if ($iptc_key == '2#025') { - $value = substr($value, 1); + $value = implode(',', + array_map('clean_iptc_value',$iptc[$iptc_key])); } - // remove binary nulls - $value = str_replace(chr(0x00), ' ', $value); - + else + { + $value = clean_iptc_value($iptc[$iptc_key][0]); + } + foreach (array_keys($map, $iptc_key) as $pwg_key) { $result[$pwg_key] = $value; @@ -70,4 +72,23 @@ function get_iptc_data($filename, $map) } return $result; } + +/** + * return a cleaned IPTC value + * + * @param string value + * @return string + */ +function clean_iptc_value($value) +{ + // strip leading zeros (weird Kodak Scanner software) + while ($value[0] == chr(0)) + { + $value = substr($value, 1); + } + // remove binary nulls + $value = str_replace(chr(0x00), ' ', $value); + + return $value; +} ?> \ No newline at end of file -- cgit v1.2.3