From 23a34783631a54703aa67aa0de81c404c59ef4ef Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 31 Jul 2005 13:50:30 +0200 Subject: optimized Image metadata handling darcs-hash:20050731115030-7ad00-2a1a423985864f0daae57545c2f3945abfc10257.gz --- inc/template.php | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) (limited to 'inc/template.php') diff --git a/inc/template.php b/inc/template.php index bbbf5bb6b..23123b452 100644 --- a/inc/template.php +++ b/inc/template.php @@ -629,30 +629,46 @@ function tpl_mediafilelist(){ } if($item['isimg']){ - $w = $item['info'][0]; - $h = $item['info'][1]; + $w = $item['meta']->getField('File.Width'); + $h = $item['meta']->getField('File.Height'); ptln('('.$w.'×'.$h.' '.filesize_h($item['size']).')',6); ptln($del.'
',6); ptln('
',6); - ptln(''); + + //build thumbnail + print ''; - if($w>120){ - print ''; - }else{ - print ''; + if($w>120 || $h>120){ + $ratio = $item['meta']->getResizeRatio(120); + $w = floor($w * $ratio); + $h = floor($h * $ratio); } + + $p = array(); + $p['w'] = $w; + $p['h'] = $h; + $p['media'] = $item['id']; + $src = DOKU_BASE.'lib/exe/fetch.php?'.buildURLParams($p); + + $p = array(); + $p['width'] = $w; + $p['height'] = $h; + $p['alt'] = $item['id']; + $p['class'] = 'thumb'; + $att = buildAttributes($p); + + print ''; print ''; //read EXIF/IPTC data - $meta = new JpegMeta(mediaFN($item['id'])); - $t = $meta->getField('IPTC.Headline'); + $t = $item['meta']->getField('IPTC.Headline'); if($t) print ''.$t.'
'; - $t = $meta->getField(array('IPTC.Caption','EXIF.UserComment','EXIF.TIFFImageDescription','EXIF.TIFFUserComment')); + $t = $item['meta']->getField(array('IPTC.Caption','EXIF.UserComment','EXIF.TIFFImageDescription','EXIF.TIFFUserComment')); if($t) print $t.'
'; - $t = $meta->getField(array('IPTC.Keywords','IPTC.Category')); + $t = $item['meta']->getField(array('IPTC.Keywords','IPTC.Category')); if($t) print ''.$t.'
'; ptln('
',6); @@ -781,15 +797,15 @@ function tpl_img($maxwidth=900,$maxheight=700){ $h = tpl_img_getTag('File.Height'); //resize to given max values - $ratio = 0; - if($w > $h){ - if($w > $maxwidth){ + $ratio = 1; + if($w >= $h){ + if($w >= $maxwidth){ $ratio = $maxwidth/$w; }elseif($h > $maxheight){ $ratio = $maxheight/$h; } }else{ - if($h > $maxheight){ + if($h >= $maxheight){ $ratio = $maxheight/$h; }elseif($w > $maxwidth){ $ratio = $maxwidth/$w; -- cgit v1.2.3