mirror of
https://github.com/e107inc/e107.git
synced 2025-01-17 20:58:30 +01:00
Include width/height attributes in img tags with cropped thumbnails.
This commit is contained in:
parent
3074814d42
commit
8660d2d890
@ -201,6 +201,7 @@ class cpage_shortcodes extends e_shortcode
|
||||
elseif($path[0] !== '{') $path = '{e_MEDIA}'.$path;
|
||||
|
||||
$thumb = $tp->thumbUrl($path);
|
||||
$dimensions = $tp->thumbDimensions('double');
|
||||
$type = varset($parms[2]['type'], 'tag');
|
||||
|
||||
switch($type)
|
||||
@ -210,12 +211,12 @@ class cpage_shortcodes extends e_shortcode
|
||||
break;
|
||||
|
||||
case 'link':
|
||||
return '<a href="'.$tp->replaceConstants($path, 'abs').'" class="cpage-image" rel="external image"><img class="cpage-image" src="'.$src.'" alt="'.varset($parms[1]['alt']).'" /></a>';
|
||||
return '<a href="'.$tp->replaceConstants($path, 'abs').'" class="cpage-image" rel="external image"><img class="cpage-image" src="'.$thumb.'" alt="'.varset($parms[1]['alt']).'" '.$dimensions.' /></a>';
|
||||
break;
|
||||
|
||||
case 'tag':
|
||||
default:
|
||||
return '<img class="cpage-image" src="'.$thumb.'" alt="'.varset($parms[1]['alt']).'" />';
|
||||
return '<img class="cpage-image" src="'.$thumb.'" alt="'.varset($parms[1]['alt']).'" '.$dimensions.' />';
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -312,8 +313,10 @@ class cpage_shortcodes extends e_shortcode
|
||||
{
|
||||
return $img;
|
||||
}
|
||||
|
||||
return "<img class='img-responsive img-rounded' src='".$img."' alt='' />";
|
||||
|
||||
$dimensions = $tp->thumbDimensions();
|
||||
|
||||
return "<img class='img-responsive img-rounded' src='".$img."' alt='' ".$dimensions." />";
|
||||
}
|
||||
|
||||
function sc_cmenuicon($parm='')
|
||||
|
@ -2177,7 +2177,19 @@ class e_parse extends e_parser
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve img tag width and height attributes for current thumbnail.
|
||||
* @return string
|
||||
*/
|
||||
public function thumbDimensions($type = 'single')
|
||||
{
|
||||
if(!empty($this->thumbCrop) && !empty($this->thumbWidth) && !empty($this->thumbHeight)) // dimensions are known.
|
||||
{
|
||||
return ($type == 'double') ? 'width="'.$this->thumbWidth.'" height="'.$this->thumbHeight.'"' : "width='".$this->thumbWidth."' height='".$this->thumbHeight."'";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user