Allow setting the image title from a metadata field during upload/import.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Tue, 1 Sep 2009 20:20:48 +0000 (16:20 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Tue, 1 Sep 2009 20:20:48 +0000 (16:20 -0400)
ansel/config/prefs.php.dist
ansel/lib/Image.php
framework/Image/lib/Horde/Image/Exif.php

index 8647514..ee2891c 100644 (file)
@@ -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
index 3b00ad4..d179552 100644 (file)
@@ -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();
 
index 94b443f..2370c33 100644 (file)
@@ -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(