mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 12:48:26 +02:00
Include width/height attributes in img tags with cropped thumbnails.
This commit is contained in:
@@ -201,6 +201,7 @@ class cpage_shortcodes extends e_shortcode
|
|||||||
elseif($path[0] !== '{') $path = '{e_MEDIA}'.$path;
|
elseif($path[0] !== '{') $path = '{e_MEDIA}'.$path;
|
||||||
|
|
||||||
$thumb = $tp->thumbUrl($path);
|
$thumb = $tp->thumbUrl($path);
|
||||||
|
$dimensions = $tp->thumbDimensions('double');
|
||||||
$type = varset($parms[2]['type'], 'tag');
|
$type = varset($parms[2]['type'], 'tag');
|
||||||
|
|
||||||
switch($type)
|
switch($type)
|
||||||
@@ -210,12 +211,12 @@ class cpage_shortcodes extends e_shortcode
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'link':
|
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;
|
break;
|
||||||
|
|
||||||
case 'tag':
|
case 'tag':
|
||||||
default:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -312,8 +313,10 @@ class cpage_shortcodes extends e_shortcode
|
|||||||
{
|
{
|
||||||
return $img;
|
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='')
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user