summaryrefslogtreecommitdiff
path: root/inc/template.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2010-06-26 16:34:26 +0200
committerAndreas Gohr <andi@splitbrain.org>2010-06-26 16:34:26 +0200
commita02d29338a87ce30f21853cf3a06bef660f2022c (patch)
tree3b4afc46ca80f90e74fb2a787f7364234ee1513a /inc/template.php
parent0636144287f7acf89c633d3d2f5214e1d229e033 (diff)
downloadrpg-a02d29338a87ce30f21853cf3a06bef660f2022c.tar.gz
rpg-a02d29338a87ce30f21853cf3a06bef660f2022c.tar.bz2
new event and parameters for tpl_img() FS#1837 FS#1564
Diffstat (limited to 'inc/template.php')
-rw-r--r--inc/template.php35
1 files changed, 27 insertions, 8 deletions
diff --git a/inc/template.php b/inc/template.php
index 20bb969ee..8847f788d 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -916,8 +916,13 @@ function tpl_img_getTag($tags,$alt='',$src=null){
* Prints the image with a link to the full sized version
*
* Only allowed in: detail.php
+ *
+ * @param $maxwidth int - maximal width of the image
+ * @param $maxheight int - maximal height of the image
+ * @param $link bool - link to the orginal size?
+ * @param $params array - additional image attributes
*/
-function tpl_img($maxwidth=0,$maxheight=0){
+function tpl_img($maxwidth=0,$maxheight=0,$link=true,$params=null){
global $IMG;
$w = tpl_img_getTag('File.Width');
$h = tpl_img_getTag('File.Height');
@@ -943,12 +948,16 @@ function tpl_img($maxwidth=0,$maxheight=0){
}
//prepare URLs
- $url=ml($IMG,array('cache'=>$_REQUEST['cache']));
- $src=ml($IMG,array('cache'=>$_REQUEST['cache'],'w'=>$w,'h'=>$h));
+ $url=ml($IMG,array('cache'=>$_REQUEST['cache']),true,'&');
+ $src=ml($IMG,array('cache'=>$_REQUEST['cache'],'w'=>$w,'h'=>$h),true,'&');
//prepare attributes
$alt=tpl_img_getTag('Simple.Title');
- $p = array();
+ if(is_null($params)){
+ $p = array();
+ }else{
+ $p = $params;
+ }
if($w) $p['width'] = $w;
if($h) $p['height'] = $h;
$p['class'] = 'img_detail';
@@ -958,11 +967,21 @@ function tpl_img($maxwidth=0,$maxheight=0){
}else{
$p['alt'] = '';
}
- $p = buildAttributes($p);
+ $p['src'] = $src;
+
+ $data = array('url'=>($link?$url:null), 'params'=>$p);
+ return trigger_event('TPL_IMG_DISPLAY',$data,'_tpl_img_action',true);
+}
+
+/**
+ * Default action for TPL_IMG_DISPLAY
+ */
+function _tpl_img_action($data, $param=NULL) {
+ $p = buildAttributes($data['params']);
- print '<a href="'.$url.'">';
- print '<img src="'.$src.'" '.$p.'/>';
- print '</a>';
+ if($data['url']) print '<a href="'.hsc($data['url']).'">';
+ print '<img '.$p.'/>';
+ if($data['url']) print '</a>';
return true;
}