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
This commit is contained in:
plegall 2004-11-20 18:07:51 +00:00
parent 13cd251e63
commit 9f037e7cea

View file

@ -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;
}
?>