From a7f6efa2f2bed248149fb2f5d3833301b92a2ecf Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 28 Nov 2008 18:04:59 +0000 Subject: When an image is uploaded (i.e. created) the tag module will now extract any iptc keywords and add them as image tags. --- modules/tag/helpers/tag.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'modules/tag/helpers') diff --git a/modules/tag/helpers/tag.php b/modules/tag/helpers/tag.php index 34ff16b6..16ed074d 100644 --- a/modules/tag/helpers/tag.php +++ b/modules/tag/helpers/tag.php @@ -97,7 +97,24 @@ class tag_Core { */ public static function on_photo_create() { $photo = Event::$data; - Kohana::log("debug", "tag::on_photo_create($photo->name)"); + $path = $photo->file_path(); + $tags = array(); + $size = getimagesize($photo->file_path(), $info); + if (is_array($info)) { + $iptc = iptcparse($info["APP13"]); + if (!empty($iptc["2#025"])) { + foreach($iptc["2#025"] as $tag) { + $tags[$tag]= 1; + } + } + } + + // @todo figure out how to read the keywords from xmp + + foreach(array_keys($tags) as $tag) { + self::add($photo, $tag); + } + return; } -- cgit v1.2.3