mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 12:48:26 +02:00
Watermark now applies site-wide when activated.
This commit is contained in:
@@ -372,6 +372,13 @@ class media_admin_ui extends e_admin_ui
|
|||||||
'im_height' => array('title'=> "Avatar Height", 'type'=>'text', 'data'=>'int', 'writeParms'=>'help=Avatar images will be constrained to these dimensions (in pixels)'),
|
'im_height' => array('title'=> "Avatar Height", 'type'=>'text', 'data'=>'int', 'writeParms'=>'help=Avatar images will be constrained to these dimensions (in pixels)'),
|
||||||
'resize_dimensions' => array('title'=> "Resize Dimensions", 'type'=>'method', 'data'=>'str'),
|
'resize_dimensions' => array('title'=> "Resize Dimensions", 'type'=>'method', 'data'=>'str'),
|
||||||
|
|
||||||
|
'watermark_activate' => array('title'=> 'Watermark Activation', 'type' => 'text', 'data' => 'str', 'help'=>'All images with a width or height greater than this value will be given a watermark during resizing.'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
|
||||||
|
'watermark_text' => array('title'=> 'Watermark Text', 'type' => 'text', 'data' => 'str', 'help'=>'Optional Watermark Text'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
|
||||||
|
'watermark_font' => array('title'=> 'Watermark Font', 'type' => 'dropdown', 'data' => 'str', 'help'=>'Optional Watermark Font. Upload more .ttf fonts to the /fonts folder in your theme directory.'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
|
||||||
|
'watermark_size' => array('title'=> 'Watermark Size', 'type' => 'text', 'data' => 'int', 'help'=>'Optional Watermark Font'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
|
||||||
|
'watermark_pos' => array('title'=> 'Watermark Position', 'type' => 'dropdown', 'data' => 'str', 'help'=>'Watermark Position'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
|
||||||
|
'watermark_opacity' => array('title'=> 'Watermark Opacity', 'type' => 'text', 'data' => 'int', 'help'=>'Enter a number between 1 and 100'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -456,6 +463,45 @@ class media_admin_ui extends e_admin_ui
|
|||||||
}
|
}
|
||||||
asort($this->cats);
|
asort($this->cats);
|
||||||
|
|
||||||
|
$pref = e107::getPref();
|
||||||
|
$tp = e107::getParser();
|
||||||
|
$fl = e107::getFile();
|
||||||
|
$path = e_THEME.$pref['sitetheme']."/fonts/";
|
||||||
|
|
||||||
|
$fDir = $fl->get_files(e_THEME.$pref['sitetheme']."/fonts/",".ttf",'',2);
|
||||||
|
$fonts = array(0=>'None');
|
||||||
|
foreach($fDir as $f)
|
||||||
|
{
|
||||||
|
$id = $tp->createConstants($f['path'].$f['fname'],'rel');
|
||||||
|
$fonts[$id] = $f['fname'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$this->prefs['watermark_font']['writeParms'] = $fonts;
|
||||||
|
$this->prefs['watermark_font']['readParms'] = $fonts;
|
||||||
|
|
||||||
|
$wm_pos = array(
|
||||||
|
'BR' => "Bottom Right",
|
||||||
|
'BL' => "Bottom Left",
|
||||||
|
'TR' => "Top Right",
|
||||||
|
'TL' => "Top Left",
|
||||||
|
'C' => "Center",
|
||||||
|
'R' => "Right",
|
||||||
|
'L' => "Left",
|
||||||
|
'T' => "Top",
|
||||||
|
'B' => "Bottom",
|
||||||
|
'*' => "Tile"
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->prefs['watermark_pos']['writeParms'] = $wm_pos;
|
||||||
|
$this->prefs['watermark_pos']['readParms'] = $wm_pos;
|
||||||
|
|
||||||
|
//FIXME TODO - clear thumbnail cache when prefs are saved/updated.
|
||||||
|
// e107::getCache()->clearAll('image');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(varset($_POST['batch_import_selected']))
|
if(varset($_POST['batch_import_selected']))
|
||||||
{
|
{
|
||||||
|
@@ -280,6 +280,12 @@ $text .= "<div class='field-section'>".$tp->parseTemplate("{IMAGESELECTOR={$parm
|
|||||||
//TODO make the preview update when image-picker is used.
|
//TODO make the preview update when image-picker is used.
|
||||||
$text .= "<div class='field-spacer'>".$tp->parseTemplate("{IMAGESELECTOR={$parms}&scaction=preview}")."</div>";
|
$text .= "<div class='field-spacer'>".$tp->parseTemplate("{IMAGESELECTOR={$parms}&scaction=preview}")."</div>";
|
||||||
|
|
||||||
|
$sLogo = siteinfo_shortcodes::sc_logo();
|
||||||
|
|
||||||
|
echo $sLogo;
|
||||||
|
// $frm->imagepicker('sitelogo',$pref['sitelogo'],'_common')
|
||||||
|
|
||||||
|
|
||||||
$text .= "
|
$text .= "
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@@ -68,12 +68,12 @@ class GdWatermarkTTF
|
|||||||
// public function WatermarkText($text, $size=12, $alignment='BR', $hex_color='000000', $ttffont='', $opacity=100, $margin=5, $angle=0, $bg_color=false, $bg_opacity=0, $fillextend='', &$that)
|
// public function WatermarkText($text, $size=12, $alignment='BR', $hex_color='000000', $ttffont='', $opacity=100, $margin=5, $angle=0, $bg_color=false, $bg_opacity=0, $fillextend='', &$that)
|
||||||
public function WatermarkText($parms, &$that)
|
public function WatermarkText($parms, &$that)
|
||||||
{
|
{
|
||||||
$text = $parms[0];
|
$text = $parms['text'];
|
||||||
$size = $parms[1];
|
$size = $parms['size'];
|
||||||
$alignment = $parms[2];
|
$alignment = $parms['pos'];
|
||||||
$hex_color = $parms[3];
|
$hex_color = $parms['color'];
|
||||||
$ttffont = $parms[4];
|
$ttffont = $parms['font'];
|
||||||
$opacity = (isset($parms[5])) ? $parms[5] : 100;
|
$opacity = (isset($parms['opacity'])) ? $parms['opacity'] : 100;
|
||||||
$margin = 30; // (isset($parms[6])) ? $parms[6] : 25;
|
$margin = 30; // (isset($parms[6])) ? $parms[6] : 25;
|
||||||
$angle = 0; // $parms['angle'];
|
$angle = 0; // $parms['angle'];
|
||||||
$bg_color = false;
|
$bg_color = false;
|
||||||
|
@@ -42,37 +42,6 @@ class gallery_shortcodes extends e_shortcode
|
|||||||
$pop_h = vartrue(e107::getPlugPref('gallery','pop_h'),768);
|
$pop_h = vartrue(e107::getPlugPref('gallery','pop_h'),768);
|
||||||
$attFull = 'w='.$pop_w.'&h='.$pop_h;
|
$attFull = 'w='.$pop_w.'&h='.$pop_h;
|
||||||
|
|
||||||
$wm_text = vartrue(e107::getPlugPref('gallery','watermark_text'));
|
|
||||||
$wm_font = vartrue(e107::getPlugPref('gallery','watermark_font'));
|
|
||||||
$wm_size = vartrue(e107::getPlugPref('gallery','watermark_size'),20);
|
|
||||||
$wm_pos = vartrue(e107::getPlugPref('gallery','watermark_pos'),"BR");
|
|
||||||
$wm_color = vartrue(e107::getPlugPref('gallery','watermark_color'),"fff");
|
|
||||||
$wm_opacity = vartrue(e107::getPlugPref('gallery','watermark_opacity'),"70");
|
|
||||||
$wm_padding = vartrue(e107::getPlugPref('gallery','watermark_padding'),"5");
|
|
||||||
|
|
||||||
/*
|
|
||||||
"wmt" (WaterMarkText)
|
|
||||||
[ex: &fltr[]=wmt|<t>|<s>|<a>|<c>|<f>|<o>|<m>|<n>]
|
|
||||||
where:
|
|
||||||
<t> is the text to use as a watermark,
|
|
||||||
<s> is the font size (1-5 for built-in font, or point
|
|
||||||
size for TrueType fonts),
|
|
||||||
<a> is the alignment (one of BR, BL, TR, TL, C, R, L,
|
|
||||||
T, B, * where B=bottom, T=top, L=left, R=right,
|
|
||||||
C=centre, *=tile),
|
|
||||||
<c> is the hex color of the text
|
|
||||||
<f> is the filename of the TTF file (optional, if
|
|
||||||
omitted a built-in font will be used)
|
|
||||||
<o> is opacity from 0 to 100,
|
|
||||||
<m> is the edge (and inter-tile) margin in percent
|
|
||||||
<n> is the angle
|
|
||||||
*/
|
|
||||||
|
|
||||||
if($wm_text)
|
|
||||||
{
|
|
||||||
$attFull .= "&wm=".$wm_text."|".$wm_size."|".$wm_pos."|".$wm_color."|".$wm_font."|".$wm_opacity."|".$wm_padding;
|
|
||||||
}
|
|
||||||
|
|
||||||
// echo "<br /><br />".$attFull;
|
// echo "<br /><br />".$attFull;
|
||||||
|
|
||||||
$text = "<a class='".$class."' title='".$tp->toAttribute($this->var['media_caption'])."' href='".$tp->thumbUrl($this->var['media_url'], $attFull)."' rel='{$rel}' >";
|
$text = "<a class='".$class."' title='".$tp->toAttribute($this->var['media_caption'])."' href='".$tp->thumbUrl($this->var['media_url'], $attFull)."' rel='{$rel}' >";
|
||||||
|
@@ -129,11 +129,6 @@ class gallery_cat_admin_ui extends e_admin_ui
|
|||||||
'popup_w' => array('title'=> 'Image Max. Width', 'type' => 'text', 'data' => 'int', 'help'=>'Images will be auto-resized if greater than the width given here'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
|
'popup_w' => array('title'=> 'Image Max. Width', 'type' => 'text', 'data' => 'int', 'help'=>'Images will be auto-resized if greater than the width given here'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
|
||||||
'popup_h' => array('title'=> 'Image Max. Height', 'type' => 'text', 'data' => 'int', 'help'=>'Images will be auto-resized if greater than the height given here'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
|
'popup_h' => array('title'=> 'Image Max. Height', 'type' => 'text', 'data' => 'int', 'help'=>'Images will be auto-resized if greater than the height given here'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
|
||||||
|
|
||||||
'watermark_text' => array('title'=> 'Watermark Text', 'type' => 'text', 'data' => 'str', 'help'=>'Optional Watermark Text'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
|
|
||||||
'watermark_font' => array('title'=> 'Watermark Font', 'type' => 'dropdown', 'data' => 'str', 'help'=>'Optional Watermark Font. Upload more .ttf fonts to the /fonts folder in your theme directory.'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
|
|
||||||
'watermark_size' => array('title'=> 'Watermark Size', 'type' => 'text', 'data' => 'int', 'help'=>'Optional Watermark Font'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
|
|
||||||
'watermark_pos' => array('title'=> 'Watermark Position', 'type' => 'dropdown', 'data' => 'str', 'help'=>'Watermark Position'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
|
|
||||||
'watermark_opacity' => array('title'=> 'Watermark Opacity', 'type' => 'text', 'data' => 'int', 'help'=>'Enter a number between 1 and 100'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
|
|
||||||
|
|
||||||
'slideshow_category' => array('title'=> 'Slideshow category', 'type' => 'dropdown', 'data' => 'str', 'help'=>'Images from this category will be used in the sliding menu.'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
|
'slideshow_category' => array('title'=> 'Slideshow category', 'type' => 'dropdown', 'data' => 'str', 'help'=>'Images from this category will be used in the sliding menu.'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
|
||||||
// 'slideshow_thumb_w' => array('title'=> 'Thumbnail Width', 'type' => 'number', 'data' => 'integer', 'help'=>'Width in px'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
|
// 'slideshow_thumb_w' => array('title'=> 'Thumbnail Width', 'type' => 'number', 'data' => 'integer', 'help'=>'Width in px'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
|
||||||
@@ -163,38 +158,7 @@ class gallery_cat_admin_ui extends e_admin_ui
|
|||||||
// 'zoom' => 'zoom'
|
// 'zoom' => 'zoom'
|
||||||
);
|
);
|
||||||
|
|
||||||
$pref = e107::getPref();
|
|
||||||
$tp = e107::getParser();
|
|
||||||
$fl = e107::getFile();
|
|
||||||
$path = e_THEME.$pref['sitetheme']."/fonts/";
|
|
||||||
|
|
||||||
$fDir = $fl->get_files(e_THEME.$pref['sitetheme']."/fonts/",".ttf",'',2);
|
|
||||||
$fonts = array(0=>'None');
|
|
||||||
foreach($fDir as $f)
|
|
||||||
{
|
|
||||||
$id = $tp->createConstants($f['path'].$f['fname'],'rel');
|
|
||||||
$fonts[$id] = $f['fname'];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$this->prefs['watermark_font']['writeParms'] = $fonts;
|
|
||||||
$this->prefs['watermark_font']['readParms'] = $fonts;
|
|
||||||
|
|
||||||
$wm_pos = array(
|
|
||||||
'BR' => "Bottom Right",
|
|
||||||
'BL' => "Bottom Left",
|
|
||||||
'TR' => "Top Right",
|
|
||||||
'TL' => "Top Left",
|
|
||||||
'C' => "Center",
|
|
||||||
'R' => "Right",
|
|
||||||
'L' => "Left",
|
|
||||||
'T' => "Top",
|
|
||||||
'B' => "Bottom",
|
|
||||||
'*' => "Tile"
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->prefs['watermark_pos']['writeParms'] = $wm_pos;
|
|
||||||
$this->prefs['watermark_pos']['readParms'] = $wm_pos;
|
|
||||||
|
|
||||||
$this->prefs['slideshow_effect']['writeParms'] = $effects;
|
$this->prefs['slideshow_effect']['writeParms'] = $effects;
|
||||||
$this->prefs['slideshow_effect']['readParms'] = $effects;
|
$this->prefs['slideshow_effect']['readParms'] = $effects;
|
||||||
|
43
thumb.php
43
thumb.php
@@ -32,6 +32,8 @@ define('e107_INIT', true);
|
|||||||
|
|
||||||
$thumbpage = new e_thumbpage();
|
$thumbpage = new e_thumbpage();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(!$thumbpage->checkSrc())
|
if(!$thumbpage->checkSrc())
|
||||||
{
|
{
|
||||||
die(' Access denied!');
|
die(' Access denied!');
|
||||||
@@ -60,6 +62,11 @@ class e_thumbpage
|
|||||||
*/
|
*/
|
||||||
protected $_src_path = null;
|
protected $_src_path = null;
|
||||||
|
|
||||||
|
|
||||||
|
/** Stores watermark prefs
|
||||||
|
*/
|
||||||
|
protected $_watermark = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor - init paths
|
* Constructor - init paths
|
||||||
* @todo FIX e107 (new folder structure), simplify all this, e.g. e107::getInstance()->initMinimal($path_to_e107_config);
|
* @todo FIX e107 (new folder structure), simplify all this, e.g. e107::getInstance()->initMinimal($path_to_e107_config);
|
||||||
@@ -116,6 +123,19 @@ class e_thumbpage
|
|||||||
|
|
||||||
// basic Admin area detection - required for proper path parsing
|
// basic Admin area detection - required for proper path parsing
|
||||||
define('ADMIN', strpos(e_SELF, ($e107->getFolder('admin')) !== false || strpos(e_PAGE, 'admin') !== false));
|
define('ADMIN', strpos(e_SELF, ($e107->getFolder('admin')) !== false || strpos(e_PAGE, 'admin') !== false));
|
||||||
|
$e107->set_urls(false);
|
||||||
|
|
||||||
|
$pref = $e107->getPref(); //TODO optimize/benchmark
|
||||||
|
|
||||||
|
$this->_watermark = array(
|
||||||
|
'activate' => vartrue($pref['watermark_activate'], false),
|
||||||
|
'text' => vartrue($pref['watermark_text']),
|
||||||
|
'size' => vartrue($pref['watermark_size'], 20),
|
||||||
|
'pos' => vartrue($pref['watermark_pos'],"BR"),
|
||||||
|
'color' => vartrue($pref['watermark_color'],'fff'),
|
||||||
|
'font' => vartrue($pref['watermark_font']),
|
||||||
|
'opacity' => vartrue($pref['watermark_opacity'], 20)
|
||||||
|
);
|
||||||
|
|
||||||
// parse request
|
// parse request
|
||||||
$this->parseRequest();
|
$this->parseRequest();
|
||||||
@@ -230,20 +250,19 @@ class e_thumbpage
|
|||||||
$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));
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Move to $_SESSION and activate based on width/height ie. watermark all images larger than....
|
// Watermark Option - See admin->MediaManager->prefs for details.
|
||||||
// ie. prevent user tampering with URLs.
|
|
||||||
if(isset($this->_request['wm']))
|
if($this->_watermark['activate'] < $options['w']
|
||||||
|
|| $this->_watermark['activate'] < $options['aw']
|
||||||
|
|| $this->_watermark['activate'] < $options['h']
|
||||||
|
|| $this->_watermark['activate'] < $options['ah']
|
||||||
|
)
|
||||||
{
|
{
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
|
$this->_watermark['font'] = $tp->createConstants($this->_watermark['font'], 'mix');
|
||||||
|
$this->_watermark['font'] = realpath($tp->replaceConstants($this->_watermark['font'],'rel'));
|
||||||
|
|
||||||
$tmp = explode("|",$this->_request['wm']);
|
$thumb->WatermarkText($this->_watermark);
|
||||||
|
|
||||||
$tmp[4] = $tp->createConstants($tmp[4], 'mix');
|
|
||||||
$tmp[4] = realpath($tp->replaceConstants($tmp[4],'rel'));
|
|
||||||
|
|
||||||
$thumb->WatermarkText($tmp);
|
|
||||||
// $alignment='BR', $hex_color='000000', $ttffont='', $opacity=100, $margin=5, $angle=0, $bg_color=false, $bg_opacity=0, $fillextend=''
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -261,7 +280,7 @@ class e_thumbpage
|
|||||||
$ret['h'] = isset($this->_request['h']) ? intval($this->_request['h']) : $ret['w'];
|
$ret['h'] = isset($this->_request['h']) ? intval($this->_request['h']) : $ret['w'];
|
||||||
$ret['aw'] = isset($this->_request['aw']) ? intval($this->_request['aw']) : false;
|
$ret['aw'] = isset($this->_request['aw']) ? intval($this->_request['aw']) : false;
|
||||||
$ret['ah'] = isset($this->_request['ah']) ? intval($this->_request['ah']) : $ret['aw'];
|
$ret['ah'] = isset($this->_request['ah']) ? intval($this->_request['ah']) : $ret['aw'];
|
||||||
$ret['wm'] = isset($this->_request['wm']) ? intval($this->_request['wm']) : $ret['wm'];
|
// $ret['wm'] = isset($this->_request['wm']) ? intval($this->_request['wm']) : $ret['wm'];
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user