summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKate Arzamastseva <pshns@ukr.net>2011-06-23 13:13:34 +0300
committerKate Arzamastseva <pshns@ukr.net>2011-06-23 13:13:34 +0300
commit532850ed047e0f35268eb1a5d4cf85c80f228dc5 (patch)
tree3f152d4a46e87e8a1eacbe58273a3da7d509a2fc
parentcf83278667fc82135e294c35d334a62318a1e39d (diff)
downloadrpg-532850ed047e0f35268eb1a5d4cf85c80f228dc5.tar.gz
rpg-532850ed047e0f35268eb1a5d4cf85c80f228dc5.tar.bz2
media getting metadata fix
-rw-r--r--conf/mediameta.php22
-rw-r--r--inc/media.php51
-rw-r--r--lib/tpl/default/detail.php46
3 files changed, 70 insertions, 49 deletions
diff --git a/conf/mediameta.php b/conf/mediameta.php
index ba7117643..8ad148aec 100644
--- a/conf/mediameta.php
+++ b/conf/mediameta.php
@@ -55,3 +55,25 @@ $fields = array(
array('Exif.Category')),
);
+
+/**
+ * This configures which meta data will be shown in details view
+ * of the media manager. Each field of the array is an array with the
+ * following contents:
+ * fieldname - Where data will be saved (EXIF or IPTC fields)
+ * label - key to lookup in the $lang var, if not found printed as is
+ * fieldtype - 'text' or 'date'
+ */
+$tags = array(
+ array('simple.title','img_title','text'),
+ array('Date.EarliestTime','img_date','date'),
+ array('File.Name','img_fname','text'),
+ array(array('Iptc.Byline','Exif.TIFFArtist','Exif.Artist','Iptc.Credit'),'img_artist','text'),
+ array(array('Iptc.CopyrightNotice','Exif.TIFFCopyright','Exif.Copyright'),'img_copyr','text'),
+ array('File.Format','img_format','text'),
+ array('File.NiceSize','img_fsize','text'),
+ array('File.Width','img_width','text'),
+ array('File.Height','img_height','text'),
+ array('Simple.Camera','img_camera','text'),
+ array(array('IPTC.Keywords','IPTC.Category','xmp.dc:subject'),'img_keywords','text')
+);
diff --git a/inc/media.php b/inc/media.php
index 68aab5415..461a13665 100644
--- a/inc/media.php
+++ b/inc/media.php
@@ -736,9 +736,8 @@ function media_tab_edit($image, $ns, $auth=null) {
echo '<div class="scroll-container">';
if ($image) {
- $info = new JpegMeta(mediaFN($image));
- if ($info->getField('File.Mime') == 'image/jpeg')
- media_metaform($image,$auth,true);
+ list($ext, $mime) = mimetype($image);
+ if ($mime == 'image/jpeg') media_metaform($image,$auth,true);
}
echo '</div>';
echo '</div>';
@@ -780,8 +779,8 @@ function media_tab_history($image, $ns, $auth=null) {
function media_preview($image, $auth, $rev=false) {
global $lang;
if ($auth < AUTH_READ || !$image) return '';
- $info = new JpegMeta(mediaFN($image));
- $w = (int) $info->getField('File.Width');
+ $info = getimagesize(mediaFN($image));
+ $w = (int) $info[0];
$more = '';
if ($rev) $more = "rev=$rev";
@@ -809,30 +808,29 @@ function media_preview($image, $auth, $rev=false) {
* @author Kate Arzamastseva <pshns@ukr.net>
*/
function media_details($image, $auth, $rev=false) {
- global $lang;
+ global $lang, $config_cascade;;
- $tags = array(
- array('simple.title','img_title','text'),
- array('Date.EarliestTime','img_date','date'),
- array('File.Name','img_fname','text'),
- array(array('Iptc.Byline','Exif.TIFFArtist','Exif.Artist','Iptc.Credit'),'img_artist','text'),
- array(array('Iptc.CopyrightNotice','Exif.TIFFCopyright','Exif.Copyright'),'img_copyr','text'),
- array('File.Format','img_format','text'),
- array('File.NiceSize','img_fsize','text'),
- array('File.Width','img_width','text'),
- array('File.Height','img_height','text'),
- array('Simple.Camera','img_camera','text'),
- array(array('IPTC.Keywords','IPTC.Category','xmp.dc:subject'),'img_keywords','text')
- );
+ // load the field descriptions
+ static $tags = null;
+ if(is_null($tags)){
+ foreach (array('default','local') as $config_group) {
+ if (empty($config_cascade['mediameta'][$config_group])) continue;
+ foreach ($config_cascade['mediameta'][$config_group] as $config_file) {
+ if(@file_exists($config_file)){
+ include($config_file);
+ }
+ }
+ }
+ }
$src = mediaFN($image, $rev);
+ $meta = new JpegMeta($src);
echo '<dl class="img_tags">';
foreach($tags as $key => $tag){
$t = $tag[0];
if (!is_array($t)) $t = array($tag[0]);
- $value = media_getTag($t,$src);
+ $value = media_getTag($t, $meta, '-');
$value = cleanText($value);
- if (!$value) $value='-';
echo '<dt>'.$lang[$tag[1]].':</dt><dd>';
if ($tag[2] == 'text') echo hsc($value);
if ($tag[2] == 'date') echo dformat($value);
@@ -842,12 +840,15 @@ function media_details($image, $auth, $rev=false) {
}
/**
- * Returns the requested EXIF/IPTC tag from the current image
+ * Returns the requested EXIF/IPTC tag from the image meta
*
+ * @author Kate Arzamastseva <pshns@ukr.net>
+ * @param array $tags
+ * @param JpegMeta $meta
+ * @param string $alt
+ * @return string
*/
-function media_getTag($tags,$src,$alt=''){
- //$meta = new JpegMeta($src);
- $meta = JpegMeta::Create($src);
+function media_getTag($tags,$meta,$alt=''){
if($meta === false) return $alt;
$info = $meta->getField($tags);
if($info == false) return $alt;
diff --git a/lib/tpl/default/detail.php b/lib/tpl/default/detail.php
index 4f42b116e..f61ede043 100644
--- a/lib/tpl/default/detail.php
+++ b/lib/tpl/default/detail.php
@@ -52,30 +52,28 @@ if (!defined('DOKU_INC')) die();
<dl class="img_tags">
<?php
- $t = tpl_img_getTag('Date.EarliestTime');
- if($t) print '<dt>'.$lang['img_date'].':</dt><dd>'.dformat($t).'</dd>';
-
- $t = tpl_img_getTag('File.Name');
- if($t) print '<dt>'.$lang['img_fname'].':</dt><dd>'.hsc($t).'</dd>';
-
- $t = tpl_img_getTag(array('Iptc.Byline','Exif.TIFFArtist','Exif.Artist','Iptc.Credit'));
- if($t) print '<dt>'.$lang['img_artist'].':</dt><dd>'.hsc($t).'</dd>';
-
- $t = tpl_img_getTag(array('Iptc.CopyrightNotice','Exif.TIFFCopyright','Exif.Copyright'));
- if($t) print '<dt>'.$lang['img_copyr'].':</dt><dd>'.hsc($t).'</dd>';
-
- $t = tpl_img_getTag('File.Format');
- if($t) print '<dt>'.$lang['img_format'].':</dt><dd>'.hsc($t).'</dd>';
-
- $t = tpl_img_getTag('File.NiceSize');
- if($t) print '<dt>'.$lang['img_fsize'].':</dt><dd>'.hsc($t).'</dd>';
-
- $t = tpl_img_getTag('Simple.Camera');
- if($t) print '<dt>'.$lang['img_camera'].':</dt><dd>'.hsc($t).'</dd>';
-
- $t = tpl_img_getTag(array('IPTC.Keywords','IPTC.Category','xmp.dc:subject'));
- if($t) print '<dt>'.$lang['img_keywords'].':</dt><dd>'.hsc($t).'</dd>';
-
+ static $tags = null;
+ if(is_null($tags)){
+ foreach (array('default','local') as $config_group) {
+ if (empty($config_cascade['mediameta'][$config_group])) continue;
+ foreach ($config_cascade['mediameta'][$config_group] as $config_file) {
+ if(@file_exists($config_file)){
+ include($config_file);
+ }
+ }
+ }
+ }
+ foreach($tags as $key => $tag){
+ $t = $tag[0];
+ if (!is_array($t)) $t = array($tag[0]);
+ $value = tpl_img_getTag($t);
+ if ($value) {
+ echo '<dt>'.$lang[$tag[1]].':</dt><dd>';
+ if ($tag[2] == 'text') echo hsc($value);
+ if ($tag[2] == 'date') echo dformat($value);
+ echo '</dd>';
+ }
+ }
?>
</dl>
<?php //Comment in for Debug// dbg(tpl_img_getTag('Simple.Raw'));?>