From 6b4e0ea33bc6cfa1269e6dca4f56f89f421921c0 Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Tue, 1 Sep 2009 16:20:48 -0400 Subject: [PATCH] Allow setting the image title from a metadata field during upload/import. --- ansel/config/prefs.php.dist | 20 ++++++++++++++++---- ansel/lib/Image.php | 7 +++++++ framework/Image/lib/Horde/Image/Exif.php | 1 + 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/ansel/config/prefs.php.dist b/ansel/config/prefs.php.dist index 8647514b4..ee2891cc1 100644 --- a/ansel/config/prefs.php.dist +++ b/ansel/config/prefs.php.dist @@ -14,9 +14,9 @@ $prefGroups['display'] = array( $prefGroups['metadata'] = array( 'column' => _("General Options"), - 'label' => _("Tags and EXIF Options"), - 'desc' => _("Change options dealing with tags and exif data."), - 'members' => array('showexif', 'exif_tags') + 'label' => _("Tags and Metadata Options"), + 'desc' => _("Change options dealing with tags and image metadata."), + 'members' => array('showexif', 'exif_tags', 'exif_title') ); $prefGroups['perms'] = array( @@ -261,8 +261,20 @@ $_prefs['exif_tags'] = array( 'locked' => false, 'shared' => false, 'type' => 'multienum', - 'desc' => _("Which Metadata fields should we automatically add as image tags during upload?"), + 'desc' => _("Which metadata fields should we automatically add as image tags during upload?"), 'enum' => Horde_Image_Exif::getFields(array($GLOBALS['conf']['exif']['driver'], !empty($GLOBALS['conf']['exif']['params']) ? $GLOBALS['conf']['exif']['params'] : array()), true) ); + +$_prefs['exif_title'] = array( + 'value' => '', + 'locked' => false, + 'shared' => false, + 'type' => 'enum', + 'desc' => _("Should we automatically set the image title on upload if able? If so, choose the field to obtain the title from."), + 'enum' => array_merge(array('none' => _("None")), + Horde_Image_Exif::getFields(array($GLOBALS['conf']['exif']['driver'], + !empty($GLOBALS['conf']['exif']['params']) ? $GLOBALS['conf']['exif']['params'] : array()), + true)) +); \ No newline at end of file diff --git a/ansel/lib/Image.php b/ansel/lib/Image.php index 3b00ad45a..d179552de 100644 --- a/ansel/lib/Image.php +++ b/ansel/lib/Image.php @@ -586,6 +586,13 @@ class Ansel_Image $needUpdate = true; } + /* Overwrite any existing value for caption with exif data */ + $exif_title = $GLOBALS['prefs']->getValue('exif_title'); + if (!empty($exif_fields[$exif_title])) { + $this->caption = $exif_fields[$exif_title]; + $needUpdate = true; + } + /* Attempt to autorotate based on Orientation field */ $this->_autoRotate(); diff --git a/framework/Image/lib/Horde/Image/Exif.php b/framework/Image/lib/Horde/Image/Exif.php index 94b443f1e..2370c33e4 100644 --- a/framework/Image/lib/Horde/Image/Exif.php +++ b/framework/Image/lib/Horde/Image/Exif.php @@ -70,6 +70,7 @@ class Horde_Image_Exif 'ObjectName' => array('description' => _("Image Title"), 'type' => 'text'), 'By-line' => array('description' => _("By"), 'type' => 'text'), 'CopyrightNotice' => array('description' => _("Copyright"), 'type' => 'text'), + 'Caption-Abstract' => array('description' => _("Caption"), 'type' => 'text'), ), 'XMP' => array( -- 2.11.0