From e2dffbe0f7d0bd1a887ba5423d4e1025103499b8 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 24 Mar 2013 03:03:31 -0700 Subject: [PATCH] {SETIMAGE} can now set Height and also crop the image. eg. {SETIMAGE: w=300&h=200&crop=1} --- e107_core/shortcodes/single/setimage.php | 3 +++ e107_handlers/e_parse_class.php | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/e107_core/shortcodes/single/setimage.php b/e107_core/shortcodes/single/setimage.php index 8acd92c6f..c14f96374 100644 --- a/e107_core/shortcodes/single/setimage.php +++ b/e107_core/shortcodes/single/setimage.php @@ -4,6 +4,9 @@ function setimage_shortcode($parm, $mode='') { e107::getParser()->thumbWidth = vartrue($parm['w'],100); + e107::getParser()->thumbHeight = vartrue($parm['h'],0); + e107::getParser()->thumbCrop = vartrue($parm['crop'],0); + } ?> diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php index d49cfd870..eb817d7aa 100644 --- a/e107_handlers/e_parse_class.php +++ b/e107_handlers/e_parse_class.php @@ -67,6 +67,8 @@ class e_parse extends e_parser var $e_query; public $thumbWidth = 100; + + public $thumbHeight = 0; // Set up the defaults var $e_optDefault = array( @@ -1834,13 +1836,23 @@ class e_parse extends e_parser $thurl = 'src='.$url.'&'; - if(vartrue($options['aw']) || vartrue($options['ah'])) + if(vartrue($options['aw']) || vartrue($options['ah']) || $this->thumbCrop == 1) { + if($this->thumbCrop == 1 && !vartrue($options['aw']) && !vartrue($options['ah'])) // Allow templates to determine dimensions. See {SETIMAGE} + { + $options['aw'] = $this->thumbWidth; + $options['ah'] = $this->thumbHeight; + } + $thurl .= 'aw='.((integer) vartrue($options['aw'], 0)).'&ah='.((integer) vartrue($options['ah'], 0)); } else { - if(!vartrue($options['w']) && !vartrue($options['h'])) $options['w'] = $this->thumbWidth; + if(!vartrue($options['w']) && !vartrue($options['h'])) // Allow templates to determine dimensions. See {SETIMAGE} + { + $options['w'] = $this->thumbWidth; + $options['h'] = $this->thumbHeight; + } $thurl .= 'w='.((integer) vartrue($options['w'], 0)).'&h='.((integer) vartrue($options['h'], 0)); }