2009-01-14
jaredm
I was writing a plugin and really needed to hook into the template image display function tpl_img(), defined in /inc/template.php and called in /lib/exe/detail.php when showing an image). This would complement the TPL_CONTENT_DISPLAY event.
This is a simple change. At the end of the tpl_img() function, remove the "print" statements and insert:
$data = array('url'=>$url, 'src'=>$src, 'p'=>$p);
return trigger_event('TPL_IMG_DISPLAY',$data,'_tpl_img_action',true);
Then create a short new function:
function _tpl_img_action($data, $param) {
print '<a href="'.$data['url'].'">';
print '<img src="'.$data['src'].'" '.$data['p'].'/>';
print '</a>';
return true;
}