From 82bb01ba711d55f4cefe3bd4e6d1a72c2b83823d Mon Sep 17 00:00:00 2001 From: chalbertgit Date: Fri, 19 Oct 2012 15:32:56 -0400 Subject: [PATCH] In IPTC, extracting an item now tries to add keywords as tags. --- 3.0/modules/iptc/helpers/iptc.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/3.0/modules/iptc/helpers/iptc.php b/3.0/modules/iptc/helpers/iptc.php index cca0f61f..70957cec 100644 --- a/3.0/modules/iptc/helpers/iptc.php +++ b/3.0/modules/iptc/helpers/iptc.php @@ -34,12 +34,12 @@ class iptc_Core { $info = getJpegHeader($item->file_path()); if ($info !== FALSE) { $iptcBlock = getIptcBlock($info); - if ($iptcBlock !== FALSE) { - $iptc = iptcparse($iptcBlock); - } else { + if ($iptcBlock !== FALSE) { + $iptc = iptcparse($iptcBlock); + } else { $iptc = array(); } - $xmp = getXmpDom($info); + $xmp = getXmpDom($info); foreach (self::keys() as $keyword => $iptcvar) { $iptc_key = $iptcvar[0]; @@ -71,6 +71,18 @@ class iptc_Core { $record->key_count = count($keys); $record->dirty = 0; $record->save(); + if (!empty($iptc['KEYWORDS']) { + $tags = explode(';', $iptc['KEYWORDS']); + foreach ($tags as $tag) { + try { + tag::add($item, $tag); + } catch (Exception $e) { + Kohana_Log::add("error", "Error adding tag: $tag\n" + . $e->getMessage() . "\n" + . $e->getTraceAsString(); + } + } + } } static function get($item) {