1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-03 13:17:24 +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. $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'); return $this->sc_newsimage('placeholder');
} }
@@ -856,7 +856,7 @@ class news_shortcodes extends e_shortcode
if(empty($srcPath)) if(empty($srcPath))
{ {
if(varset($parm['type']) == 'placeholder' || vartrue($parm['placeholder'])) if(varset($parm['type']) == 'placeholder' || !empty($parm['placeholder']))
{ {
$src = $tp->thumbUrl(); // placeholder; $src = $tp->thumbUrl(); // placeholder;
$dimensions = $tp->thumbDimensions(); $dimensions = $tp->thumbDimensions();
@@ -899,8 +899,9 @@ class news_shortcodes extends e_shortcode
$imgParms = array( $imgParms = array(
'class'=>$class, 'class'=>$class,
'alt'=>basename($src), 'alt'=>basename($srcPath),
'style'=>$style 'style'=>$style,
'placeholder'=>varset($parm['placeholder'])
); );

View File

@@ -3962,28 +3962,33 @@ class e_parser
public function toImage($file, $parm=array()) public function toImage($file, $parm=array())
{ {
if(empty($file))
{
return null;
}
if(strpos($file,'e_AVATAR')!==false) if(strpos($file,'e_AVATAR')!==false)
{ {
return "<div class='alert alert-danger'>Use \$tp->toAvatar() instead of toImage() for ".$file."</div>"; // debug info only. return "<div class='alert alert-danger'>Use \$tp->toAvatar() instead of toImage() for ".$file."</div>"; // debug info only.
} }
if(empty($file) && empty($parm['placeholder']))
{
return null;
}
if(!empty($file))
{
$srcset = null; $srcset = null;
$path = null; $path = null;
$file = trim($file); $file = trim($file);
$ext = pathinfo($file, PATHINFO_EXTENSION); $ext = pathinfo($file, PATHINFO_EXTENSION);
$accepted = array('jpg','gif','png','jpeg'); $accepted = array('jpg','gif','png','jpeg');
$tp = $this;
if(!in_array($ext,$accepted)) if(!in_array($ext,$accepted))
{ {
return null; return null;
} }
}
$tp = $this;
// e107::getDebug()->log($file); // e107::getDebug()->log($file);
// e107::getDebug()->log($parm); // e107::getDebug()->log($parm);
@@ -4047,7 +4052,10 @@ class e_parser
$path = $file; $path = $file;
} }
if(empty($path) && !empty($parm['placeholder']))
{
$path = $tp->thumbUrl($file,$parm);
}
$id = (!empty($parm['id'])) ? "id=\"".$parm['id']."\" " : "" ; $id = (!empty($parm['id'])) ? "id=\"".$parm['id']."\" " : "" ;
$class = (!empty($parm['class'])) ? $parm['class'] : "img-responsive img-fluid"; $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" > $NEWS_GRID_TEMPLATE['other']['featured'] = '<div class="featured item col-sm-6" >
{SETIMAGE: w=600&h=400&crop=1} {SETIMAGE: w=600&h=400&crop=1}
{NEWSTHUMBNAIL=placeholder} {NEWSTHUMBNAIL=placeholder}
<h3>{NEWS_TITLE}</h3> <h3><a href="{NEWS_URL}">{NEWS_TITLE}</a></h3>
<p>{NEWS_SUMMARY}</p> <p>{NEWS_SUMMARY: limit=60}</p>
</div> </div>
@@ -91,13 +91,13 @@
<ul class="media-list"> <ul class="media-list">
<li class="media"> <li class="media">
<div class="media-left media-top"> <div class="media-left media-top">
<a href="#"> <a href="{NEWS_URL}">
{NEWS_IMAGE: class=media-object img-rounded} {NEWS_IMAGE: class=media-object img-rounded&placeholder=1}
</a> </a>
</div> </div>
<div class="media-body"> <div class="media-body">
<h4 class="media-heading">{NEWS_TITLE}</h4> <h4 class="media-heading"><a href="{NEWS_URL}">{NEWS_TITLE}</a></h4>
<p>{NEWS_SUMMARY}</p> <p>{NEWS_SUMMARY: limit=60}</p>
</div> </div>
</li> </li>
</ul> </ul>