Beispiel #1
0
 /**
  * Tests whether the GD library is installed and enabled
  *
  * @return void
  */
 private function test_GD()
 {
     if (extension_loaded('gd') && function_exists('gd_info')) {
         self::$GDEnabled = true;
     } else {
         self::$GDEnabled = false;
     }
 }
 private static function addWatermark($imagePath, $imagePost, $target)
 {
     if (!class_exists('EW_Plugin')) {
         return $imagePath;
     }
     $ewPlugin = new \EW_Plugin();
     $ewPlugin->plugin_init();
     $prop = new \ReflectionProperty('EW_Plugin', 'currentImage');
     if ($prop) {
         $prop->setAccessible(true);
         $prop->setValue($ewPlugin, $imagePost);
     }
     $ew = $ewPlugin->getEasyWatermark();
     $imageType = 'image/jpeg';
     $ew->setImagePath($imagePath)->setImageMime($imageType)->setOutputFile($target)->setOutputMime($imageType);
     if (!$ew->create() || !$ew->saveOutput()) {
         return $imagePath;
         // $error = $ew->getError();
         // throw new \Exception("Error: $error");
     }
     $ew->clean();
     return $target;
 }
Beispiel #3
0
<?php

/*
Plugin Name:	Easy Watermark
Description:	This plugin can automatically add image and text watermark to pictures as they are uploaded to wordpress media library. You can also watermark existing images manually (all at once or an every single image). Watermark image can be a png, gif (alpha channel supported in both cases) or jpg. It's also possibile to set watermark opacity (doesn't apply to png with alpha channel). For text watermark you can select font, set color, size, angel and opacity.
Version:		0.6.0
Author:		Wojtek Szałkiewicz
Author URI:	http://szalkiewicz.pl/
License:		GPLv2 or later
License URI:	http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: easy-watermark
*/
// Define flag, that we have plugin loaded
define('EASY_WATERMARK', true);
define('EWDS', DIRECTORY_SEPARATOR);
define('EWBASE', dirname(__FILE__));
define('EWLIB', EWBASE . EWDS . 'lib');
define('EWCLASSES', EWBASE . EWDS . 'classes');
define('EWVIEWS', EWBASE . EWDS . 'views');
// Require all needed files
require_once EWCLASSES . EWDS . 'class-ew-pluggable.php';
require_once EWCLASSES . EWDS . 'class-ew-plugin-core.php';
require_once EWCLASSES . EWDS . 'class-ew-plugin.php';
require_once EWCLASSES . EWDS . 'class-ew-settings.php';
require_once EWLIB . EWDS . 'EasyWatermark.php';
// Initiate plugin
EW_Plugin::init();
Beispiel #4
0
echo $text;
?>
" id="title" placeholder="<?php 
_e('Watermark Text', 'easy-watermark');
?>
" name="easy-watermark-settings-text[text]" />
				<p class="description"><?php 
_e('You can use placeholders. See help.', 'easy-watermark');
?>
</p>
			</div>
			<?php 
$class = empty($text) ? ' class="hidden"' : '';
?>
			<?php 
if (EW_Plugin::isGDEnabled()) {
    ?>
			<div<?php 
    echo $class;
    ?>
 id="ew-preview-row"><?php 
    _e('Preview', 'easy-watermark');
    ?>
<br/>
				<div id="text-preview" style="width:100%; overflow:auto;">
						<img id="ew-text-preview" src="<?php 
    echo admin_url('options-general.php?page=easy-watermark-settings&tp=1');
    ?>
">
				</div>
			</div>