1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 20:30:39 +02:00

tp->toImage() now accepts 'placeholder' parm. NewsGrid template now uses placeholder by default.

This commit is contained in:
Cameron
2017-03-04 10:06:53 -08:00
parent 0f42d516e7
commit aaa5db36ab
3 changed files with 34 additions and 25 deletions

View File

@@ -733,7 +733,7 @@ class news_shortcodes extends e_shortcode
$this->imageItem = varset($media[$parm['item']]); // Set the current Image for other image shortcodes.
if(vartrue($parm['placeholder']))
if(!empty($parm['placeholder']))
{
return $this->sc_newsimage('placeholder');
}
@@ -853,10 +853,10 @@ class news_shortcodes extends e_shortcode
}
else
{
if(empty($srcPath))
{
if(varset($parm['type']) == 'placeholder' || vartrue($parm['placeholder']))
if(varset($parm['type']) == 'placeholder' || !empty($parm['placeholder']))
{
$src = $tp->thumbUrl(); // placeholder;
$dimensions = $tp->thumbDimensions();
@@ -899,8 +899,9 @@ class news_shortcodes extends e_shortcode
$imgParms = array(
'class'=>$class,
'alt'=>basename($src),
'style'=>$style
'alt'=>basename($srcPath),
'style'=>$style,
'placeholder'=>varset($parm['placeholder'])
);

View File

@@ -3962,29 +3962,34 @@ class e_parser
public function toImage($file, $parm=array())
{
if(empty($file))
{
return null;
}
if(strpos($file,'e_AVATAR')!==false)
{
return "<div class='alert alert-danger'>Use \$tp->toAvatar() instead of toImage() for ".$file."</div>"; // debug info only.
}
$srcset = null;
$path = null;
$file = trim($file);
$ext = pathinfo($file, PATHINFO_EXTENSION);
$accepted = array('jpg','gif','png','jpeg');
$tp = $this;
if(!in_array($ext,$accepted))
if(empty($file) && empty($parm['placeholder']))
{
return null;
}
if(!empty($file))
{
$srcset = null;
$path = null;
$file = trim($file);
$ext = pathinfo($file, PATHINFO_EXTENSION);
$accepted = array('jpg','gif','png','jpeg');
if(!in_array($ext,$accepted))
{
return null;
}
}
$tp = $this;
// e107::getDebug()->log($file);
// e107::getDebug()->log($parm);
@@ -4047,7 +4052,10 @@ class e_parser
$path = $file;
}
if(empty($path) && !empty($parm['placeholder']))
{
$path = $tp->thumbUrl($file,$parm);
}
$id = (!empty($parm['id'])) ? "id=\"".$parm['id']."\" " : "" ;
$class = (!empty($parm['class'])) ? $parm['class'] : "img-responsive img-fluid";

View File

@@ -78,8 +78,8 @@
$NEWS_GRID_TEMPLATE['other']['featured'] = '<div class="featured item col-sm-6" >
{SETIMAGE: w=600&h=400&crop=1}
{NEWSTHUMBNAIL=placeholder}
<h3>{NEWS_TITLE}</h3>
<p>{NEWS_SUMMARY}</p>
<h3><a href="{NEWS_URL}">{NEWS_TITLE}</a></h3>
<p>{NEWS_SUMMARY: limit=60}</p>
</div>
@@ -91,13 +91,13 @@
<ul class="media-list">
<li class="media">
<div class="media-left media-top">
<a href="#">
{NEWS_IMAGE: class=media-object img-rounded}
<a href="{NEWS_URL}">
{NEWS_IMAGE: class=media-object img-rounded&placeholder=1}
</a>
</div>
<div class="media-body">
<h4 class="media-heading">{NEWS_TITLE}</h4>
<p>{NEWS_SUMMARY}</p>
<h4 class="media-heading"><a href="{NEWS_URL}">{NEWS_TITLE}</a></h4>
<p>{NEWS_SUMMARY: limit=60}</p>
</div>
</li>
</ul>