diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-04-09 16:30:49 +0000 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-04-09 16:30:49 +0000 |
commit | fe9b08e50636d8e66c0cd72306e2833314146bcc (patch) | |
tree | 93fd8d6dfec8dc42fd024e18bd6fe80dfe48dbb7 /core | |
parent | d558a8801532f7882cf62bd814243e56d8a166cc (diff) |
Merge the micro_thumb_tag method into thumb_tag and add a third
parameter to indicate that a micro thumb is being generated
Diffstat (limited to 'core')
-rw-r--r-- | core/models/item.php | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/core/models/item.php b/core/models/item.php index 156080c2..80000afa 100644 --- a/core/models/item.php +++ b/core/models/item.php @@ -353,10 +353,17 @@ class Item_Model extends ORM_MPTT { * Return an <img> tag for the thumbnail. * @param array $extra_attrs Extra attributes to add to the img tag * @param int (optional) $max Maximum size of the thumbnail (default: null) + * @param boolean (optional) $micro_thumb Center vertically (default: false) * @return string */ - public function thumb_tag($extra_attrs=array(), $max=null) { + public function thumb_tag($extra_attrs=array(), $max=null, $micro_thumb=false) { list ($height, $width) = $this->_adjust_thumb_size($max); + if ($micro_thumb && $max) { + // The constant is divide by 2 to calcuate the file and 10 to convert to em + $margin_top = ($max - $height) / 20; + $extra_attrs["style"] = "margin-top: {$margin_top}em"; + $extra_attrs["title"] = $this->title; + } $attrs = array_merge($extra_attrs, array( "src" => $this->thumb_url(), @@ -369,30 +376,6 @@ class Item_Model extends ORM_MPTT { } /** - * Return an <img> tag for a micro thumbnail. Use margins to center within the specified size - * @param array $extra_attrs Extra attributes to add to the img tag - * @param int (optional) $max Maximum size of the thumbnail (default: null) - * @return string - */ - public function micro_thumb_tag($extra_attrs=array(), $max=null) { - list ($height, $width) = $this->_adjust_thumb_size($max); - // The constant is divide by 2 to calcuate the file and 10 to convert to em - $margin_top = ($max - $height) / 20; - $extra_attrs["style"] = "margin-top: {$margin_top}em"; - - $attrs = array_merge($extra_attrs, - array( - "src" => $this->thumb_url(), - "alt" => $this->title, - "title" => $this->title, - "width" => $width, - "height" => $height) - ); - // html::image forces an absolute url which we don't want - return "<img" . html::attributes($attrs) . "/>"; - } - - /** * Adjust the height based on the input maximum size or zero if not thumbnail * @param int $max Maximum size of the thumbnail * @return array |