mirror of
https://github.com/e107inc/e107.git
synced 2025-08-06 06:38:00 +02:00
Bulk mail templates can now resize images to keep email sizes smaller. eg. {MEDIA1: w=500} Improved debugging of thumb.php.
This commit is contained in:
@@ -591,8 +591,11 @@ class mailout_main_ui extends e_admin_ui
|
||||
'template' => vartrue($_POST['testtemplate'],null),
|
||||
'shortcodes' => $this->getExampleShortcodes(),
|
||||
'media' => array(
|
||||
0 => array('path' => '{e_PLUGIN}gallery/images/butterfly.jpg'),
|
||||
1 => array('path' => 'h-v880sXEOQ.youtube'),
|
||||
0 => array('path' => '{e_PLUGIN}gallery/images/butterfly.jpg'),
|
||||
1 => array('path' => 'h-v880sXEOQ.youtube'),
|
||||
2 => array('path' => '{e_PLUGIN}gallery/images/horse.jpg'),
|
||||
3 => array('path' => '{e_PLUGIN}gallery/images/butterfly.jpg'),
|
||||
4 => array('path' => '{e_PLUGIN}gallery/images/horse.jpg'),
|
||||
)
|
||||
);
|
||||
|
||||
@@ -952,7 +955,7 @@ class mailout_main_ui extends e_admin_ui
|
||||
$pause = e107::getConfig()->get('mail_pausetime',1);
|
||||
$interval = ($pause * 1000);
|
||||
|
||||
$text = e107::getForm()->progressBar('mail-progress',1, array('btn-label'=>'Start', 'interval'=>$interval, 'url'=> e_SELF, 'mode'=>$id));
|
||||
$text = e107::getForm()->progressBar('mail-progress',0, array('btn-label'=>'Start', 'interval'=>$interval, 'url'=> e_SELF, 'mode'=>$id));
|
||||
}
|
||||
|
||||
return $text;
|
||||
|
@@ -734,7 +734,27 @@ class e107Email extends PHPMailer
|
||||
function processShortcodes($eml)
|
||||
{
|
||||
$tp = e107::getParser();
|
||||
|
||||
|
||||
$mediaParms = array();
|
||||
|
||||
|
||||
|
||||
if(strpos($eml['templateHTML']['body'], '{MEDIA') !==false )
|
||||
{
|
||||
// check for media sizing.
|
||||
|
||||
if(preg_match_all('/\{MEDIA([\d]): w=([\d]*)\}/', $eml['templateHTML']['body'], $match))
|
||||
{
|
||||
|
||||
foreach($match[1] as $k=>$num)
|
||||
{
|
||||
//$key = $match[1][$k];
|
||||
$mediaParms[$num]['w'] = $match[2][$k];
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($eml['html']) || strip_tags($eml['template']) != $eml['template']) // HTML Email.
|
||||
{
|
||||
$eml['shortcodes']['BODY'] = !empty($eml['body']) ? $eml['body'] : ''; // using toEmail() on html templates adds unnecessary <br /> to code.
|
||||
@@ -747,15 +767,17 @@ class e107Email extends PHPMailer
|
||||
$eml['shortcodes']['BODY'] = !empty($eml['body']) ? $eml['body'] : ''; // $tp->toEmail($eml['body']) : '';
|
||||
$eml['shortcodes']['SUBJECT'] = !empty($eml['subject']) ?$eml['subject'] : '';
|
||||
$eml['shortcodes']['THEME'] = ($this->previewMode == true) ? e_THEME_ABS.$this->pref['sitetheme'].'/' : e_THEME.$this->pref['sitetheme'].'/'; // Always use front-end theme path.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if(!empty($eml['media']) && is_array($eml['media']))
|
||||
{
|
||||
foreach($eml['media'] as $k=>$val)
|
||||
{
|
||||
if(vartrue($val['path']))
|
||||
{
|
||||
$id = 'MEDIA'.($k+1);
|
||||
$nk = ($k+1);
|
||||
$id = 'MEDIA'.$nk;
|
||||
|
||||
if($tp->isVideo($val['path']))
|
||||
{
|
||||
@@ -763,7 +785,9 @@ class e107Email extends PHPMailer
|
||||
}
|
||||
else
|
||||
{
|
||||
$eml['shortcodes'][$id] = "<div class='media media-image'><img class='img-responsive' src='".$val['path']."' alt='' /></div>";
|
||||
$size = isset($mediaParms[$nk]) ? "?w=".$mediaParms[$nk]['w'] : '';
|
||||
//echo $nk.": ".$val['path'].$size."<br />";
|
||||
$eml['shortcodes'][$id] = "<div class='media media-image'><img class='img-responsive ".strtolower($id)."' src='".$val['path'].$size."' alt='' /></div>";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -809,7 +833,7 @@ class e107Email extends PHPMailer
|
||||
|
||||
if($tmpl = e107::getCoreTemplate('email', $eml['template'], 'front', true)) //FIXME - Core template is failing with template 'notify'. Works with theme template. Issue with core template registry?
|
||||
{
|
||||
|
||||
$eml['templateHTML'] = $tmpl;
|
||||
$eml['shortcodes'] = $this->processShortcodes($eml);
|
||||
|
||||
$emailBody = $tmpl['header']. str_replace('{BODY}', $eml['body'], $tmpl['body']) . $tmpl['footer'];
|
||||
@@ -1118,12 +1142,21 @@ class e107Email extends PHPMailer
|
||||
{
|
||||
$url = $tp->replaceConstants($url);
|
||||
|
||||
$size = 'w=800';
|
||||
|
||||
if(strpos($url, '?w=')!==false)
|
||||
{
|
||||
list($url,$size) = explode('?', $url);
|
||||
}
|
||||
|
||||
// resize on the fly.
|
||||
if($this->debug)
|
||||
{
|
||||
echo "<br />Attempting Resize...".$url;
|
||||
|
||||
}
|
||||
if($resized = e107::getMedia()->resizeImage($url, e_TEMP.basename($url),'w=800'))
|
||||
// e107::getMessage()->addInfo("Resizing: ".$url." to ".$size);
|
||||
if($resized = e107::getMedia()->resizeImage($url, e_TEMP.basename($url), $size))
|
||||
{
|
||||
$url = $resized;
|
||||
}
|
||||
|
@@ -67,6 +67,7 @@ class plugin_gallery_index_controller extends eControllerFront
|
||||
public function init()
|
||||
{
|
||||
e107::plugLan('gallery', 'front');
|
||||
e107::css('gallery', 'css/gallery.css');
|
||||
$this->catList = e107::getMedia()->getCategories('gallery');
|
||||
}
|
||||
|
||||
|
50
thumb.php
50
thumb.php
@@ -48,6 +48,10 @@ exit;
|
||||
|
||||
class e_thumbpage
|
||||
{
|
||||
private $_debug = false;
|
||||
|
||||
private $_cache = true;
|
||||
|
||||
/**
|
||||
* Page request
|
||||
* @var array
|
||||
@@ -232,7 +236,13 @@ class e_thumbpage
|
||||
$parm = array('size' => $width."x".$height);
|
||||
|
||||
$this->placeholder($parm);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if($this->_debug === true)
|
||||
{
|
||||
var_dump($this->_request);
|
||||
// return false;
|
||||
}
|
||||
|
||||
if(!$this->_src_path)
|
||||
@@ -246,17 +256,19 @@ class e_thumbpage
|
||||
$cache_str = md5(serialize($options). $this->_src_path. $this->_thumbQuality);
|
||||
$fname = strtolower('Thumb_'.$thumbnfo['filename'].'_'.$cache_str.'.'.$thumbnfo['extension']).'.cache.bin';
|
||||
|
||||
|
||||
|
||||
if(is_file(e_CACHE_IMAGE.$fname) && is_readable(e_CACHE_IMAGE.$fname))
|
||||
|
||||
if($this->_cache = true && is_file(e_CACHE_IMAGE.$fname) && is_readable(e_CACHE_IMAGE.$fname) && ($this->_debug !== true))
|
||||
{
|
||||
$thumbnfo['lmodified'] = filemtime(e_CACHE_IMAGE.$fname);
|
||||
$thumbnfo['md5s'] = md5_file(e_CACHE_IMAGE.$fname);
|
||||
$thumbnfo['fsize'] = filesize(e_CACHE_IMAGE.$fname);
|
||||
|
||||
// Send required headers
|
||||
$this->sendHeaders($thumbnfo);
|
||||
|
||||
if($this->_debug !== true)
|
||||
{
|
||||
$this->sendHeaders($thumbnfo);
|
||||
}
|
||||
|
||||
//$bench->end()->logResult('thumb.php', $_GET['src'].' - 304 not modified');
|
||||
// exit;
|
||||
@@ -278,11 +290,15 @@ class e_thumbpage
|
||||
}
|
||||
|
||||
// TODO - wrap it around generic e107 thumb handler
|
||||
if($this->_debug === true)
|
||||
{
|
||||
$start = microtime(true);
|
||||
}
|
||||
@require(e_HANDLER.'phpthumb/ThumbLib.inc.php');
|
||||
try
|
||||
{
|
||||
$thumb = PhpThumbFactory::create($this->_src_path);
|
||||
$sizeUp = ($this->_request['w'] > 110) ? true : false; // don't resizeUp the icon images.
|
||||
$sizeUp = ($this->_request['w'] > 110 || $this->_request['aw'] > 110) ? true : false; // don't resizeUp the icon images.
|
||||
$thumb->setOptions(array(
|
||||
'correctPermissions' => true,
|
||||
'resizeUp' => $sizeUp,
|
||||
@@ -300,16 +316,26 @@ class e_thumbpage
|
||||
if(isset($this->_request['w']) || isset($this->_request['h']))
|
||||
{
|
||||
$thumb->resize((integer) vartrue($this->_request['w'], 0), (integer) vartrue($this->_request['h'], 0));
|
||||
echo __LINE__;
|
||||
}
|
||||
elseif(vartrue($this->_request['ah']))
|
||||
elseif(!empty($this->_request['ah']))
|
||||
{
|
||||
//Typically gives a better result with images of people than adaptiveResize().
|
||||
//TODO TBD Add Pref for Top, Bottom, Left, Right, Center?
|
||||
$thumb->adaptiveResizeQuadrant((integer) vartrue($this->_request['aw'], 0), (integer) vartrue($this->_request['ah'], 0), 'T');
|
||||
//TODO TBD Add Pref for Top, Bottom, Left, Right, Center?
|
||||
$thumb->adaptiveResizeQuadrant((integer) vartrue($this->_request['aw'], 0), (integer) vartrue($this->_request['ah'], 0), 'T');
|
||||
}
|
||||
else
|
||||
{
|
||||
$thumb->adaptiveResize((integer) vartrue($this->_request['aw'], 0), (integer) vartrue($this->_request['ah'], 0));
|
||||
$thumb->adaptiveResize((integer) vartrue($this->_request['aw'], 0), (integer) vartrue($this->_request['ah'], 0));
|
||||
}
|
||||
|
||||
|
||||
if($this->_debug === true)
|
||||
{
|
||||
echo "time: ".round((microtime(true) - $start),4);
|
||||
|
||||
var_dump($thumb);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Watermark Option - See admin->MediaManager->prefs for details.
|
||||
@@ -327,13 +353,15 @@ class e_thumbpage
|
||||
$thumb->WatermarkText($this->_watermark);
|
||||
}
|
||||
// echo "hello";
|
||||
|
||||
|
||||
|
||||
|
||||
//exit;
|
||||
|
||||
// set cache
|
||||
$thumb->save(e_CACHE_IMAGE.$fname);
|
||||
|
||||
|
||||
|
||||
// show thumb
|
||||
$thumb->show();
|
||||
|
Reference in New Issue
Block a user