diff --git a/e107_core/shortcodes/batch/news_shortcodes.php b/e107_core/shortcodes/batch/news_shortcodes.php
index 9e61c4e11..459ebc78f 100644
--- a/e107_core/shortcodes/batch/news_shortcodes.php
+++ b/e107_core/shortcodes/batch/news_shortcodes.php
@@ -469,6 +469,8 @@ class news_shortcodes extends e_shortcode
$class = 'news-thumbnail-'.$tmp['count'];
$dimensions = null;
+ $srcset = null;
+ $tp = e107::getParser();
if(!$newsThumb && $parm != 'placeholder')
{
@@ -486,7 +488,7 @@ class news_shortcodes extends e_shortcode
if(empty($parms[2])) // get {SETIMAGE} values when no parm provided.
{
- $parms[2] = array('aw' => e107::getParser()->thumbWidth(), 'ah'=> e107::getParser()->thumbHeight());
+ $parms[2] = array('aw' => $tp->thumbWidth(), 'ah'=> $tp->thumbHeight());
}
@@ -513,8 +515,10 @@ class news_shortcodes extends e_shortcode
if($parms[2] || $parms[1] == 'placeholder')
{
+ // $srcset = "srcset='".$tp->thumbSrcSet($src,'all')."' size='100vw' ";
$src = e107::getParser()->thumbUrl($src, $parms[2]);
$dimensions = e107::getParser()->thumbDimensions();
+
}
}
@@ -528,15 +532,15 @@ class news_shortcodes extends e_shortcode
break;
case 'tag':
- return "
";
+ return "
";
break;
case 'img':
- return "
";
+ return "
";
break;
default:
- return "news_item)."'>
";
+ return "news_item)."'>
";
break;
}
}
@@ -660,7 +664,7 @@ class news_shortcodes extends e_shortcode
$class = "news_image news-image img-responsive img-rounded";
$class .= ' news-image-'.$tmp['count'];
$dimensions = null;
-
+ $srcset = null;
if($tp->isVideo($srcPath))
{
@@ -685,6 +689,7 @@ class news_shortcodes extends e_shortcode
{
$src = $tp->thumbUrl($srcPath);
$dimensions = $tp->thumbDimensions();
+
}
else
{
@@ -717,12 +722,12 @@ class news_shortcodes extends e_shortcode
break;
case 'tag':
- return "
";
+ return "
";
break;
case 'url':
default:
- return "news_item)."'>
";
+ return "news_item)."'>
";
break;
}
}
diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php
index ea0ae17f5..446c0c414 100644
--- a/e107_handlers/e_parse_class.php
+++ b/e107_handlers/e_parse_class.php
@@ -2300,6 +2300,56 @@ class e_parse extends e_parser
return $baseurl.$thurl;
}
+
+ /**
+ * Experimental: Generate a Thumb URL for use in the img srcset attribute.
+ * @param string $src eg. {e_MEDIA_IMAGE}myimage.jpg
+ * @param int|str $width - desired size in px or '2x' or '3x' or null for all
+ * @return string
+ */
+ function thumbSrcSet($src='', $width=null)
+ {
+
+ if($width == null || $width=='all')
+ {
+ $links = array();
+ $mag = ($width == null) ? array(1, 2) : array(160,320,460,600,780,920,1100);
+ foreach($mag as $v)
+ {
+ $w = ($this->thumbWidth * $v);
+ $h = ($this->thumbHeight * $v);
+
+ $parms = !empty($this->thumbCrop) ? array('aw' => $w, 'ah' => $h) : array('w' => $w, 'h' => $h);
+
+ $add = ($width == null) ? " ".$v."x" : " ".$v."w";
+ $links[] = $this->thumbUrl($src, $parms).$add; // " w".$width; //
+ }
+
+ return implode(", ",$links);
+
+ }
+ elseif($width == '2x')
+ {
+ $width = ($this->thumbWidth * 2);
+ $height = ($this->thumbHeight * 2);
+ }
+ elseif($width == '3x')
+ {
+ $width = ($this->thumbWidth * 3);
+ $height = ($this->thumbHeight * 3);
+ }
+ else
+ {
+ $height = (($this->thumbHeight * $width) / $this->thumbWidth);
+ }
+
+ $parms = !empty($this->thumbCrop) ? array('aw' => $width, 'ah' => $height) : array('w' => $width, 'h' => $height );
+
+ return $this->thumbUrl($src, $parms)." ".$width."w";
+
+ }
+
+
/**
* Used by thumbUrl when SEF Image URLS is active. @see e107.htaccess
* @param $url
@@ -3395,6 +3445,13 @@ class e_parser
{
$path = $tp->thumbUrl($file,null,null,true);
$dimensions = $this->thumbDimensions();
+ $width2x = ($parm['w']*2);
+ $height2x = ($parm['h']*2);
+
+ $path2x = $tp->thumbUrl($file,array('w'=> $width2x ,'h'=> $height2x ));
+
+ print_a($path2x);
+
}
elseif($file[0] == '{') // Legacy v1.x path. Example: {e_WHEREEVER}
{