diff options
author | Andreas Gohr <andi@splitbrain.org> | 2005-07-24 14:50:47 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2005-07-24 14:50:47 +0200 |
commit | 2684e50a0796d39e424969890c16eb97a8838151 (patch) | |
tree | 848f781cec60c964e20b0f2a193b7d81a5433a54 /inc | |
parent | 55efc227eaeb2d480ff22837b78f89766b07fe5f (diff) | |
download | rpg-2684e50a0796d39e424969890c16eb97a8838151.tar.gz rpg-2684e50a0796d39e424969890c16eb97a8838151.tar.bz2 |
some minor fixes in image detail handling
darcs-hash:20050724125047-7ad00-a03fa69aed22694f6b7635923b1f2ce564165b9f.gz
Diffstat (limited to 'inc')
-rw-r--r-- | inc/JpegMeta.php | 3 | ||||
-rw-r--r-- | inc/common.php | 34 | ||||
-rw-r--r-- | inc/parser/xhtml.php | 2 | ||||
-rw-r--r-- | inc/template.php | 26 |
4 files changed, 57 insertions, 8 deletions
diff --git a/inc/JpegMeta.php b/inc/JpegMeta.php index f3ee97b91..656e98625 100644 --- a/inc/JpegMeta.php +++ b/inc/JpegMeta.php @@ -431,7 +431,8 @@ class JpegMeta 'Iptc.Caption', 'Exif.UserComment', 'Exif.TIFFUserComment', - 'Exif.TIFFImageDescription')); + 'Exif.TIFFImageDescription', + 'File.Name')); if (empty($cap)) return false; if(!$max) return $cap; diff --git a/inc/common.php b/inc/common.php index f40c8f1fd..eadef5767 100644 --- a/inc/common.php +++ b/inc/common.php @@ -77,6 +77,40 @@ function pageinfo(){ } /** + * Build an string of URL parameters + * + * @author Andreas Gohr + */ +function buildURLparams($params){ + $url = ''; + $amp = false; + foreach($params as $key => $val){ + if($amp) $url .= '&'; + + $url .= $key.'='; + $url .= urlencode($val); + $amp = true; + } + return $url; +} + +/** + * Build an string of html tag attributes + * + * @author Andreas Gohr + */ +function buildAttributes($params){ + $url = ''; + foreach($params as $key => $val){ + $url .= $key.'="'; + $url .= htmlspecialchars ($val); + $url .= '" '; + } + return $url; +} + + +/** * print a message * * If HTTP headers were not sent yet the message is added diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index b633260ac..81f0b2dca 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -708,7 +708,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $link['title'] = $this->_xmlEntities($src); list($ext,$mime) = mimetype($src); - if(substr($mime,0,5) == 'image'){ + if(substr($mime,0,5) == 'image' && !preg_match('#^(https?|ftp)://#i',$src)){ $link['url']= DOKU_BASE.'lib/exe/detail.php?id='.$ID.'&cache='.$cache.'&media='.urlencode($src); }else{ $link['url']= DOKU_BASE.'lib/exe/fetch.php?cache='.$cache.'&media='.urlencode($src); diff --git a/inc/template.php b/inc/template.php index d9b0454f1..3a86930be 100644 --- a/inc/template.php +++ b/inc/template.php @@ -765,15 +765,29 @@ function tpl_img($maxwidth=900,$maxheight=700){ $h = floor($ratio*$h); } - //FIXME add alt attribute, classes - - $url=DOKU_BASE.'lib/exe/fetch.php?cache='.urlencode($_REQUEST['cache']). - '&media='.urlencode($IMG); - + //prepare URL + $p = array(); + $p['cache'] = $_REQUEST['cache']; + $p['media'] = $IMG; + $p = buildURLparams($p); + $url=DOKU_BASE.'lib/exe/fetch.php?'.$p; + + //prepare attributes $alt=tpl_img_getTag('Simple.Title'); + $p = array(); + if($w) $p['width'] = $w; + if($h) $p['height'] = $h; + $p['class'] = 'img_detail'; + if($alt){ + $p['alt'] = $alt; + $p['title'] = $alt; + }else{ + $p['alt'] = ''; + } + $p = buildAttributes($p); print '<a href="'.$url.'">'; - print '<img src="'.$url.'&w='.$w.'&h='.$w.'" width="'.$w.'" height="'.$h.'" />'; + print '<img src="'.$url.'&w='.$w.'&h='.$w.'" '.$p.'/>'; print '</a>'; } |