Easy Watermark - Version 0.1

Version Description

  • Initial release
Download this release

Release Info

Developer szaleq
Plugin Icon Easy Watermark
Version 0.1
Comparing to
See all releases

Version 0.1

easy-watermark-settings.php ADDED
@@ -0,0 +1,123 @@
1
+ <?php
2
+
3
+ if(!class_exists('EasyWatermarkSettings')) :
4
+
5
+ class EasyWatermarkSettings
6
+ {
7
+ private $tabs = array();
8
+
9
+ private $options = array();
10
+
11
+ private static $defaults = array(
12
+ 'auto_add' => true,
13
+ 'image_types' => array('jpeg' => 'jpeg', 'png' => 'png', 'gif' => 'gif'),
14
+ 'image' => array(
15
+ 'url' => null,
16
+ 'path' => null,
17
+ 'id' => null,
18
+ 'mime' => null,
19
+ 'position-vert' => 'btm',
20
+ 'offset-vert' => 100,
21
+ 'position-horizontal' => 'lft',
22
+ 'offset-horizontal' => 100,
23
+ 'alpha' => 100,
24
+ )
25
+ );
26
+
27
+ public static function getDefaults(){
28
+ return self::$defaults;
29
+ }
30
+
31
+ public function __construct(){
32
+
33
+ add_action('admin_menu', array($this, 'add_options_page'));
34
+ add_action('admin_init', array($this, 'register_settings'));
35
+
36
+ add_filter('plugin_action_links', array($this, 'settings_link'), 10, 2);
37
+
38
+ $this->options = get_option('easy-watermark-settings');
39
+ }
40
+
41
+ public function get($key){
42
+ return $this->options[$key];
43
+ }
44
+
45
+ public function add_options_page(){
46
+ add_options_page( 'Easy Watermark Settings', 'Easy Watermark Settings', 'manage_options', 'easy-watermark-settings', array($this, 'settings_page'));
47
+ }
48
+
49
+ public function register_settings(){
50
+ register_setting(
51
+ 'easy-watermark-settings',
52
+ 'easy-watermark-settings',
53
+ array($this, 'sanitize_settings')
54
+ );
55
+ }
56
+
57
+ public function sanitize_settings($input){
58
+ if(!isset($input['auto_add']) || $input['auto_add'] !== '1'){
59
+ $input['auto_add'] = false;
60
+ }
61
+
62
+ if(!isset($input['image_types'])){
63
+ $input['image_types'] = array();
64
+ }
65
+
66
+ if(!empty($input['image']['url'])){
67
+ if(isset($input['old-manager'])){
68
+ // old wordpress media library, we have only image url
69
+ global $wpdb;
70
+
71
+ $row = $wpdb->get_row("
72
+ SELECT ID, post_mime_type
73
+ FROM $wpdb->posts
74
+ WHERE $wpdb->posts.post_type = 'attachment'
75
+ AND $wpdb->posts.guid = '{$input['image']['url']}'
76
+ ");
77
+
78
+ $input['image']['id'] = $row->ID;
79
+ $input['image']['mime'] = $row->post_mime_type;
80
+ unset($input['old-manager']);
81
+ }
82
+
83
+ $input['image']['path'] = get_attached_file($input['image']['id']);
84
+ }
85
+
86
+ $input = wp_parse_args($input, $this->options);
87
+
88
+ return $input;
89
+ }
90
+
91
+ public function settings_page(){
92
+ wp_enqueue_script('ew-interface', plugin_dir_url(dirname(__FILE__) . '/easy-watermark.php') . 'js/interface.js');
93
+ if(function_exists('wp_enqueue_media')){
94
+ // load new media manager (since wp 3.5)
95
+ wp_enqueue_media();
96
+ wp_enqueue_script('ew-media-libraby', plugin_dir_url(dirname(__FILE__) . '/easy-watermark.php') . 'js/media-library.js');
97
+ }
98
+ else {
99
+ // load old-style thiskbox
100
+ wp_enqueue_script('thickbox');
101
+ wp_enqueue_style('thickbox');
102
+ wp_enqueue_script('ew-media-libraby', plugin_dir_url(dirname(__FILE__) . '/easy-watermark.php') . 'js/old-media-library.js');
103
+ }
104
+
105
+ $options = $this->options;
106
+ include dirname(__FILE__) . '/settings-form.php';
107
+ }
108
+
109
+ function settings_link($links, $file){
110
+ static $this_plugin;
111
+
112
+ if (!$this_plugin) {
113
+ $this_plugin = plugin_basename(dirname(__FILE__) . '/easy-watermark.php');
114
+ }
115
+ if ($file == $this_plugin) {
116
+ $settings_link = '<a href="options-general.php?page=easy-watermark-settings">'.__('Settings').'</a>';
117
+ array_unshift($links, $settings_link);
118
+ }
119
+ return $links;
120
+ }
121
+ }
122
+
123
+ endif;
easy-watermark.php ADDED
@@ -0,0 +1,281 @@
1
+ <?php
2
+ /*
3
+ Plugin Name: Easy Watermark
4
+ Description: This plugin allows you to add image watermark to every single image or all images from library at once. It can also be configured to automatically watermark new images as they are uploaded. Watermark can be a png, gif (alpha channel supported in both cases) or jpg image. It's also possibile to set watermark opacity (doesn't apply to png with alpha channel).
5
+ Version: 0.1
6
+ Author: Wojtek Szałkiewicz
7
+ Author URI: http://szalkiewicz.pl/
8
+ */
9
+ include dirname(__FILE__) . '/easy-watermark-settings.php';
10
+
11
+ if(!class_exists('EasyWatermark')) :
12
+
13
+ class EasyWatermark
14
+ {
15
+ private $settings;
16
+
17
+ private $messages = array();
18
+
19
+ public function __construct(){
20
+ load_plugin_textdomain('easy-watermark', false, '/easy-watermark/languages');
21
+
22
+ add_action('admin_menu', array($this, 'add_media_page'));
23
+ add_action('add_attachment', array($this, 'add_watermark_after_upload'));
24
+ add_filter('media_row_actions', array($this, 'add_media_row_action'), 10, 3);
25
+ add_filter( 'attachment_fields_to_edit', array($this, 'add_attachment_field'), 10, 2 );
26
+
27
+ $this->settings = new EasyWatermarkSettings();
28
+ }
29
+
30
+ public function add_attachment_field($form_fields, $post){
31
+ $form_fields = array_reverse($form_fields);
32
+ $form_fields['easy-watermark'] = array(
33
+ 'label' => '<a href="'.wp_nonce_url(admin_url('upload.php?page=easy-watermark&attachment_id='.$post->ID.'&')).'" class="button-secondary">'.__('Add watermark').'</a>',
34
+ 'input' => 'html',
35
+ 'html' => ' '
36
+ );
37
+ return array_reverse($form_fields);
38
+ }
39
+
40
+ public function add_watermark_after_upload($id){
41
+ if($this->settings->get('auto_add')){
42
+ $this->add_watermark($id, true);
43
+ }
44
+ }
45
+
46
+ private function add_watermark($id, $mimecheck = false){
47
+ $watermark = $this->settings->get('image');
48
+ if($watermark['path'] != ''){
49
+ $post = get_post($id);
50
+ $filepath = get_attached_file($id);
51
+
52
+ if(strpos($post->post_mime_type, 'image/') !== 0 || in_array($post->post_mime_type, array('png', 'jpeg', 'gif'))){
53
+ $this->add_error('Invalid mime type.');
54
+ return false;
55
+ }
56
+
57
+ $imgMime = substr($post->post_mime_type, 6);
58
+ $wmMime = substr($watermark['mime'], 6);
59
+
60
+ if($mimecheck && !in_array($imgMime, $this->settings->get('image_types'))){
61
+ return false;
62
+ }
63
+
64
+ return $this->create_watermark($filepath, $imgMime, $watermark['path'], $wmMime, $filepath);
65
+ }
66
+ else {
67
+ $this->add_error('No watermark image selected.');
68
+ return false;
69
+ }
70
+ }
71
+
72
+ private function watermark_all(){
73
+ global $wpdb;
74
+
75
+ $images = $wpdb->get_results("
76
+ SELECT ID, post_mime_type
77
+ FROM $wpdb->posts
78
+ WHERE post_type = 'attachment'
79
+ AND post_mime_type LIKE 'image/%'
80
+ ");
81
+
82
+ $output = '';
83
+ $watermark = $this->settings->get('image');
84
+ if($images && $watermark['path'] != ''){
85
+ $wmMime = substr($watermark['mime'], 6);
86
+ foreach($images as $img){
87
+ $filepath = get_attached_file($img->ID);
88
+ $imgMime = substr($img->post_mime_type, 6);
89
+ if(!in_array($imgMime, $this->settings->get('image_types'))){
90
+ $output .= $filepath.': wrong mime type. Skipping...<br/>';
91
+ continue;
92
+ }
93
+
94
+ if($this->create_watermark($filepath, $imgMime, $watermark['path'], $wmMime, $filepath)){
95
+ $output .= $filepath.': watermark added.<br/>';
96
+ }
97
+ }
98
+ }
99
+
100
+ $output = '<p>'.$output.'</p>';
101
+
102
+ return $output;
103
+ }
104
+
105
+ private function create_watermark($imageFile, $imageType, $watermarkFile, $watermarkType, $outputFile){
106
+ if($imageFile != $watermarkFile){
107
+ $settings = $this->settings->get('image');
108
+ $alpha = $settings['alpha'];
109
+
110
+ $imgfunc = 'imagecreatefrom' . $imageType;
111
+ $watermarkfunc = 'imagecreatefrom' . $watermarkType;
112
+
113
+ $image = $imgfunc($imageFile);
114
+ if($imageType == 'png'){
115
+ imagealphablending($image, false);
116
+ imagesavealpha($image, true);
117
+ }
118
+ $watermark = $watermarkfunc($watermarkFile);
119
+
120
+ $imageWidth = imagesx($image);
121
+ $imageHeight = imagesy($image);
122
+
123
+ $watermarkWidth = imagesx($watermark);
124
+ $watermarkHeight = imagesy($watermark);
125
+
126
+ $offsetX = 0;
127
+ $offsetY = 0;
128
+ switch($settings['position-horizontal']){
129
+ case 'lft':
130
+ $offsetX = $settings['offset-horizontal'];
131
+ break;
132
+ case 'ctr':
133
+ $offsetX = ($imageWidth - $watermarkWidth) / 2;
134
+ break;
135
+ case 'rgt':
136
+ $offsetX = $imageWidth - $watermarkWidth - $settings['offset-horizontal'];
137
+ break;
138
+ }
139
+ switch($settings['position-vert']){
140
+ case 'top':
141
+ $offsetY = $settings['offset-vert'];
142
+ break;
143
+ case 'mdl':
144
+ $offsetY = ($imageHeight - $watermarkHeight) / 2;
145
+ break;
146
+ case 'btm':
147
+ $offsetY = $imageHeight - $watermarkHeight - $settings['offset-vert'];
148
+ break;
149
+ }
150
+
151
+ $params = array(
152
+ $image,
153
+ $watermark,
154
+ $offsetX, $offsetY,
155
+ 0, 0,
156
+ $watermarkWidth, $watermarkHeight
157
+ );
158
+
159
+ if($watermarkType == 'png' && $this->is_alpha_png($watermarkFile)){
160
+ $imgcopyfunc = 'imagecopy';
161
+ }
162
+ else {
163
+ $imgcopyfunc = 'imagecopymerge';
164
+ $params[] = $alpha;
165
+ }
166
+ call_user_func_array($imgcopyfunc, $params);
167
+
168
+ $createfunc = 'image'.$imageType;
169
+ $createfunc($image, $outputFile);
170
+
171
+ imageDestroy($image);
172
+ imageDestroy($watermark);
173
+
174
+ return true;
175
+ }
176
+ else {
177
+ $this->add_error('Can\'t add watermark to itself!');
178
+
179
+ return false;
180
+ }
181
+ }
182
+
183
+ public function add_media_page(){
184
+ add_media_page( 'Easy Watermark', 'Easy Watermark', 'upload_files', 'easy-watermark', array($this, 'easy_watermark'));
185
+ }
186
+
187
+ public function easy_watermark(){
188
+ ?>
189
+ <div class="wrap easy-watermark">
190
+ <h2><?php _e('Easy Watermark', 'easy-watermark'); ?></h2>
191
+ <?php
192
+ if(isset($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'])){
193
+ if(isset($_GET['attachment_id'])){
194
+ if($this->add_watermark($_GET['attachment_id'])) :
195
+ ?>
196
+ <div id="message" class="updated below-h2">
197
+ <p><?php _e('Watermark successfully added.', 'easy-watermark'); ?> <a href="javascript:window.history.go(-1)"><?php _e('Go back', 'easy-watermark'); ?></a> or <a href="<?php echo get_edit_post_link($_GET['attachment_id']); ?>"><?php _e('go to edit page', 'easy-watermark'); ?></a></p>
198
+ </div>
199
+ <?php
200
+ else :
201
+ foreach($this->messages as $msg) :
202
+ ?>
203
+ <div id="message" class="<?php echo $msg[0]; ?> below-h2">
204
+ <p><?php _e($msg[1], 'easy-watermark'); ?></p>
205
+ </div>
206
+ <a href="javascript:window.history.go(-1)"><?php _e('Go back', 'easy-watermark'); ?></a> or <a href="<?php echo get_edit_post_link($_GET['attachment_id']); ?>"><?php _e('go to edit page', 'easy-watermark'); ?></a>
207
+ <?php
208
+ endforeach;
209
+ endif;
210
+ }
211
+ elseif(isset($_GET['watermark_all'])){
212
+ if($output = $this->watermark_all()) :
213
+ ?>
214
+ <div id="message" class="updated below-h2">
215
+ <p><?php _e('Watermark successfully added.', 'easy-watermark'); ?> <a href="<?php echo admin_url('upload.php') ?>"><?php _e('Go to Media Library', 'easy-watermark'); ?></a></p>
216
+ </div>
217
+ <?
218
+ echo $output;
219
+ endif;
220
+ }
221
+ }
222
+ else {
223
+ ?>
224
+ <br/><a class="button-primary" href="<?php echo wp_nonce_url(admin_url('/upload.php?page=easy-watermark&watermark_all=1')); ?>"><?php _e('Add watermark to all images', 'easy-watermark'); ?></a><p class="description"><?php _e('Be carefull with that option. If some images alredy has watermark, it will be added though.'); ?></p>
225
+ <?php
226
+ $settings = $this->settings->get('image');
227
+ }
228
+ ?>
229
+ </div>
230
+ <?php
231
+ }
232
+
233
+ public function add_media_row_action($actions, $post, $detached){
234
+ $actions['add_watermark'] = '<a href="' . wp_nonce_url(admin_url('upload.php?page=easy-watermark&attachment_id='.$post->ID)) . '">Add Watermark</a>';
235
+ return $actions;
236
+ }
237
+
238
+ public static function install(){
239
+ add_option('easy-watermark-settings', EasyWatermarkSettings::getDefaults());
240
+ }
241
+
242
+ public static function uninstall(){
243
+ delete_option('easy-watermark-settings');
244
+ }
245
+
246
+ private function add_error($msg){
247
+ $this->messages[] = array('error', $msg);
248
+ }
249
+
250
+ private function add_info($msg){
251
+ $this->messages[] = array('update', $msg);
252
+ }
253
+
254
+ public function is_alpha_png($file){
255
+ /* color type of png image stored at 25 byte:
256
+ * 0 - greyscale
257
+ * 2 - RGB
258
+ * 3 - RGB with palette
259
+ * 4 - greyscale + alpha
260
+ * 6 - RGB + alpha
261
+ */
262
+ $colorByte = ord(@file_get_contents($file, false, null, 25, 1));
263
+ return ($colorByte == 6 || $colorByte == 4);
264
+ }
265
+ }
266
+
267
+ register_activation_hook(__FILE__, array('EasyWatermark', 'install'));
268
+ register_uninstall_hook(__FILE__, array('EasyWatermark', 'uninstall'));
269
+
270
+ endif;
271
+
272
+ if(!function_exists('initEasyWatermark')) :
273
+
274
+ function initEasyWatermark(){
275
+ if(is_admin())
276
+ $easyWatermark = new EasyWatermark();
277
+ }
278
+ add_action('init', 'initEasyWatermark');
279
+
280
+ endif;
281
+
js/interface.js ADDED
@@ -0,0 +1,21 @@
1
+ (function($){
2
+ if($('#easy-watermark-autoadd').attr('checked'))
3
+ $('.auto-add-options').show();
4
+
5
+ $('#easy-watermark-autoadd').change(function(){
6
+ var checked = $(this).attr('checked');
7
+ if(checked)
8
+ $('.auto-add-options').show();
9
+ else
10
+ $('.auto-add-options').hide();
11
+ });
12
+
13
+ $('.remove-image').click(function(e){
14
+ e.preventDefault();
15
+
16
+ $('#easy-watermark-url').val('');
17
+ $('#easy-watermark-id').val('');
18
+ $('#easy-watermark-mime').val('');
19
+ $('#easy-watermark-settings-form').submit();
20
+ });
21
+ }(jQuery))
js/media-library.js ADDED
@@ -0,0 +1,37 @@
1
+ (function($){
2
+ var frame;
3
+
4
+ $('#select-image-button, #watermark-preview').click( function( event ) {
5
+ var $el = $(this);
6
+ event.preventDefault();
7
+
8
+ if ( frame ) {
9
+ frame.open();
10
+ return;
11
+ }
12
+
13
+ frame = wp.media.frames.customHeader = wp.media({
14
+ title: $el.data('choose'),
15
+
16
+ library: {
17
+ type: 'image'
18
+ },
19
+
20
+ button: {
21
+ text: $el.data('buttonLabel'),
22
+ close: true
23
+ }
24
+ });
25
+
26
+ frame.on( 'select', function() {
27
+ // Grab the selected attachment.
28
+ var attachment = frame.state().get('selection').first();
29
+ $('#easy-watermark-url').val(attachment.attributes.url);
30
+ $('#easy-watermark-mime').val(attachment.attributes.mime);
31
+ $('#easy-watermark-id').val(attachment.id);
32
+ $('#easy-watermark-settings-form').submit();
33
+ });
34
+
35
+ frame.open();
36
+ });
37
+ }(jQuery))
js/old-media-library.js ADDED
@@ -0,0 +1,16 @@
1
+ (function($){
2
+ var frame;
3
+
4
+ $('#select-image-button, #watermark-preview').click( function( event ) {
5
+ var $el = $(this);
6
+ event.preventDefault();
7
+
8
+ tb_show("", "media-upload.php?type=image&amp;TB_iframe=1");
9
+ });
10
+ window.send_to_editor = function(html) {
11
+ var imgurl = $('img',html).attr('src');
12
+ $('#easy-watermark-url').val(imgurl);
13
+ tb_remove();
14
+ $('#easy-watermark-settings-form').append('<input type="hidden" name="easy-watermark-settings[old-manager]" value="1" />').submit();
15
+ }
16
+ }(jQuery))
languages/easy-watermark-pl_PL.mo ADDED
Binary file
languages/easy-watermark-pl_PL.po ADDED
@@ -0,0 +1,172 @@
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Easy Watermark 0.1\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2013-03-21 20:55+0100\n"
6
+ "PO-Revision-Date: 2013-03-21 21:03+0100\n"
7
+ "Last-Translator: Wojtek Szałkiewicz <wojtek@szalkiewicz.pl>\n"
8
+ "Language-Team: Wojtek Szałkiewicz <szaleq@gmail.com>\n"
9
+ "Language: \n"
10
+ "MIME-Version: 1.0\n"
11
+ "Content-Type: text/plain; charset=UTF-8\n"
12
+ "Content-Transfer-Encoding: 8bit\n"
13
+ "X-Poedit-KeywordsList: __;_e\n"
14
+ "X-Poedit-Basepath: .\n"
15
+ "X-Poedit-Language: polish\n"
16
+ "X-Poedit-SearchPath-0: /media/szaleq/Data/easy-watermark/0.1\n"
17
+
18
+ #: /media/szaleq/Data/easy-watermark/0.1/easy-watermark-settings.php:116
19
+ msgid "Settings"
20
+ msgstr "Ustawienia"
21
+
22
+ #: /media/szaleq/Data/easy-watermark/0.1/easy-watermark.php:33
23
+ msgid "Add watermark"
24
+ msgstr "Dodaj znak wodny"
25
+
26
+ #: /media/szaleq/Data/easy-watermark/0.1/easy-watermark.php:190
27
+ msgid "Easy Watermark"
28
+ msgstr ""
29
+
30
+ #: /media/szaleq/Data/easy-watermark/0.1/easy-watermark.php:197
31
+ #: /media/szaleq/Data/easy-watermark/0.1/easy-watermark.php:215
32
+ msgid "Watermark successfully added."
33
+ msgstr "Znak wodny został dodany."
34
+
35
+ #: /media/szaleq/Data/easy-watermark/0.1/easy-watermark.php:197
36
+ #: /media/szaleq/Data/easy-watermark/0.1/easy-watermark.php:206
37
+ msgid "Go back"
38
+ msgstr "Wróć"
39
+
40
+ #: /media/szaleq/Data/easy-watermark/0.1/easy-watermark.php:197
41
+ #: /media/szaleq/Data/easy-watermark/0.1/easy-watermark.php:206
42
+ msgid "go to edit page"
43
+ msgstr "idź na stronę edycji"
44
+
45
+ #: /media/szaleq/Data/easy-watermark/0.1/easy-watermark.php:215
46
+ msgid "Go to Media Library"
47
+ msgstr "Idź do biblioteki mediów"
48
+
49
+ #: /media/szaleq/Data/easy-watermark/0.1/easy-watermark.php:224
50
+ msgid "Add watermark to all images"
51
+ msgstr "Dodaj znak wodny do wszystkich obrazów"
52
+
53
+ #: /media/szaleq/Data/easy-watermark/0.1/easy-watermark.php:224
54
+ msgid "Be carefull with that option. If some images alredy has watermark, it will be added though."
55
+ msgstr "Bądź ostrożny używając tej opcji. Jeśli jakieś zdjęcia mają już znak wodny, zostanie on dodany po raz drugi."
56
+
57
+ #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:6
58
+ msgid "Easy Watermark Settings"
59
+ msgstr "Ustawienia Easy Watermark"
60
+
61
+ #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:6
62
+ msgid "Go to Easy Watermark Tool"
63
+ msgstr "Otwórz Easy Watermark"
64
+
65
+ #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:9
66
+ msgid "General settings"
67
+ msgstr "Ustawienia główne"
68
+
69
+ #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:11
70
+ msgid "Auto watermark"
71
+ msgstr "Automatyczne dodawanie"
72
+
73
+ #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:12
74
+ msgid "Add watermark when uploading images"
75
+ msgstr "Dodawaj znak wodny podczas wgrywania obrazów"
76
+
77
+ #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:14
78
+ msgid "Image types"
79
+ msgstr "Typy obrazów"
80
+
81
+ #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:18
82
+ msgid "Select image types which should be watermarked"
83
+ msgstr "Zaznacz typy obrazów, które mają być oznaczane znakiem wodnym"
84
+
85
+ #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:21
86
+ msgid "Watermark settings"
87
+ msgstr "Ustawienia znaku wodnego"
88
+
89
+ #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:23
90
+ msgid "Watermark image"
91
+ msgstr "Znak wodny"
92
+
93
+ #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:32
94
+ msgid "Choose Watermark Image"
95
+ msgstr "Wybierz znak wodny"
96
+
97
+ #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:32
98
+ msgid "Set as Watermark Image"
99
+ msgstr "Ustaw jako znak wodny"
100
+
101
+ #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:32
102
+ msgid "Select/Upload Image"
103
+ msgstr "Wybierz/wgraj obraz"
104
+
105
+ #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:40
106
+ msgid "Loading preview..."
107
+ msgstr "Ładowanie podglądu..."
108
+
109
+ #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:41
110
+ msgid "Click on image to change it."
111
+ msgstr "Kliknij na obraz by go zmienić."
112
+
113
+ #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:41
114
+ msgid "Remove image"
115
+ msgstr "Usuń obraz"
116
+
117
+ #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:42
118
+ msgid "Note: if \"Auto watermark\" option is ticked, untick it before uploading new watermark image or remove current image first."
119
+ msgstr "Uwaga: Jeśli opcja \"Automatycznie dodawanie\" jest zaznaczona, odznacz ją przed wgrywaniem nowego znaku wodnego lub usuń najpierw bieżący znak wodny."
120
+
121
+ #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:46
122
+ msgid "Watermark position"
123
+ msgstr "Pozycja znaku"
124
+
125
+ #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:47
126
+ msgid "vertical"
127
+ msgstr "pionowa"
128
+
129
+ #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:48
130
+ msgid "top"
131
+ msgstr "góra"
132
+
133
+ #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:49
134
+ msgid "middle"
135
+ msgstr "środek"
136
+
137
+ #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:50
138
+ msgid "bottom"
139
+ msgstr "dół"
140
+
141
+ #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:51
142
+ msgid "offset"
143
+ msgstr ""
144
+
145
+ #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:52
146
+ msgid "horizontal"
147
+ msgstr "pozioma"
148
+
149
+ #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:53
150
+ msgid "left"
151
+ msgstr "do lewej"
152
+
153
+ #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:54
154
+ msgid "center"
155
+ msgstr "wyśrodkowany"
156
+
157
+ #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:55
158
+ msgid "right"
159
+ msgstr "do prawej"
160
+
161
+ #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:60
162
+ msgid "Opacity"
163
+ msgstr "Nieprzezroczystość"
164
+
165
+ #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:60
166
+ msgid "Opacity does not affect the png images with alpha chanel."
167
+ msgstr "Ta opcja nie dotyczy obrazów png posiadających kanał alfa."
168
+
169
+ #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:66
170
+ msgid "Save Changes"
171
+ msgstr "Zapisz zmiany"
172
+
languages/easy-watermark.pot ADDED
@@ -0,0 +1,171 @@
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Easy Watermark 0.1\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2013-03-22 14:32+0100\n"
6
+ "PO-Revision-Date: 2013-03-22 14:33+0100\n"
7
+ "Last-Translator: Wojtek Szałkiewicz <wojtek@szalkiewicz.pl>\n"
8
+ "Language-Team: Wojtek Szałkiewicz <szaleq@gmail.com>\n"
9
+ "Language: \n"
10
+ "MIME-Version: 1.0\n"
11
+ "Content-Type: text/plain; charset=UTF-8\n"
12
+ "Content-Transfer-Encoding: 8bit\n"
13
+ "X-Poedit-KeywordsList: __;_e\n"
14
+ "X-Poedit-Basepath: .\n"
15
+ "X-Poedit-SearchPath-0: /home/szaleq/easy-watermark/trunk\n"
16
+
17
+ #: /home/szaleq/easy-watermark/trunk/settings-form.php:6
18
+ msgid "Easy Watermark Settings"
19
+ msgstr ""
20
+
21
+ #: /home/szaleq/easy-watermark/trunk/settings-form.php:6
22
+ msgid "Go to Easy Watermark Tool"
23
+ msgstr ""
24
+
25
+ #: /home/szaleq/easy-watermark/trunk/settings-form.php:9
26
+ msgid "General settings"
27
+ msgstr ""
28
+
29
+ #: /home/szaleq/easy-watermark/trunk/settings-form.php:11
30
+ msgid "Auto watermark"
31
+ msgstr ""
32
+
33
+ #: /home/szaleq/easy-watermark/trunk/settings-form.php:12
34
+ msgid "Add watermark when uploading images"
35
+ msgstr ""
36
+
37
+ #: /home/szaleq/easy-watermark/trunk/settings-form.php:14
38
+ msgid "Image types"
39
+ msgstr ""
40
+
41
+ #: /home/szaleq/easy-watermark/trunk/settings-form.php:18
42
+ msgid "Select image types which should be watermarked"
43
+ msgstr ""
44
+
45
+ #: /home/szaleq/easy-watermark/trunk/settings-form.php:21
46
+ msgid "Watermark settings"
47
+ msgstr ""
48
+
49
+ #: /home/szaleq/easy-watermark/trunk/settings-form.php:23
50
+ msgid "Watermark image"
51
+ msgstr ""
52
+
53
+ #: /home/szaleq/easy-watermark/trunk/settings-form.php:32
54
+ msgid "Choose Watermark Image"
55
+ msgstr ""
56
+
57
+ #: /home/szaleq/easy-watermark/trunk/settings-form.php:32
58
+ msgid "Set as Watermark Image"
59
+ msgstr ""
60
+
61
+ #: /home/szaleq/easy-watermark/trunk/settings-form.php:32
62
+ msgid "Select/Upload Image"
63
+ msgstr ""
64
+
65
+ #: /home/szaleq/easy-watermark/trunk/settings-form.php:40
66
+ msgid "Loading preview..."
67
+ msgstr ""
68
+
69
+ #: /home/szaleq/easy-watermark/trunk/settings-form.php:41
70
+ msgid "Click on image to change it."
71
+ msgstr ""
72
+
73
+ #: /home/szaleq/easy-watermark/trunk/settings-form.php:41
74
+ msgid "Remove image"
75
+ msgstr ""
76
+
77
+ #: /home/szaleq/easy-watermark/trunk/settings-form.php:42
78
+ msgid "Note: if \"Auto watermark\" option is ticked, untick it before uploading new watermark image or remove current image first."
79
+ msgstr ""
80
+
81
+ #: /home/szaleq/easy-watermark/trunk/settings-form.php:46
82
+ msgid "Watermark position"
83
+ msgstr ""
84
+
85
+ #: /home/szaleq/easy-watermark/trunk/settings-form.php:47
86
+ msgid "vertical"
87
+ msgstr ""
88
+
89
+ #: /home/szaleq/easy-watermark/trunk/settings-form.php:48
90
+ msgid "top"
91
+ msgstr ""
92
+
93
+ #: /home/szaleq/easy-watermark/trunk/settings-form.php:49
94
+ msgid "middle"
95
+ msgstr ""
96
+
97
+ #: /home/szaleq/easy-watermark/trunk/settings-form.php:50
98
+ msgid "bottom"
99
+ msgstr ""
100
+
101
+ #: /home/szaleq/easy-watermark/trunk/settings-form.php:51
102
+ msgid "offset"
103
+ msgstr ""
104
+
105
+ #: /home/szaleq/easy-watermark/trunk/settings-form.php:52
106
+ msgid "horizontal"
107
+ msgstr ""
108
+
109
+ #: /home/szaleq/easy-watermark/trunk/settings-form.php:53
110
+ msgid "left"
111
+ msgstr ""
112
+
113
+ #: /home/szaleq/easy-watermark/trunk/settings-form.php:54
114
+ msgid "center"
115
+ msgstr ""
116
+
117
+ #: /home/szaleq/easy-watermark/trunk/settings-form.php:55
118
+ msgid "right"
119
+ msgstr ""
120
+
121
+ #: /home/szaleq/easy-watermark/trunk/settings-form.php:60
122
+ msgid "Opacity"
123
+ msgstr ""
124
+
125
+ #: /home/szaleq/easy-watermark/trunk/settings-form.php:60
126
+ msgid "Opacity does not affect the png images with alpha chanel."
127
+ msgstr ""
128
+
129
+ #: /home/szaleq/easy-watermark/trunk/settings-form.php:66
130
+ msgid "Save Changes"
131
+ msgstr ""
132
+
133
+ #: /home/szaleq/easy-watermark/trunk/easy-watermark.php:33
134
+ msgid "Add watermark"
135
+ msgstr ""
136
+
137
+ #: /home/szaleq/easy-watermark/trunk/easy-watermark.php:190
138
+ msgid "Easy Watermark"
139
+ msgstr ""
140
+
141
+ #: /home/szaleq/easy-watermark/trunk/easy-watermark.php:197
142
+ #: /home/szaleq/easy-watermark/trunk/easy-watermark.php:215
143
+ msgid "Watermark successfully added."
144
+ msgstr ""
145
+
146
+ #: /home/szaleq/easy-watermark/trunk/easy-watermark.php:197
147
+ #: /home/szaleq/easy-watermark/trunk/easy-watermark.php:206
148
+ msgid "Go back"
149
+ msgstr ""
150
+
151
+ #: /home/szaleq/easy-watermark/trunk/easy-watermark.php:197
152
+ #: /home/szaleq/easy-watermark/trunk/easy-watermark.php:206
153
+ msgid "go to edit page"
154
+ msgstr ""
155
+
156
+ #: /home/szaleq/easy-watermark/trunk/easy-watermark.php:215
157
+ msgid "Go to Media Library"
158
+ msgstr ""
159
+
160
+ #: /home/szaleq/easy-watermark/trunk/easy-watermark.php:224
161
+ msgid "Add watermark to all images"
162
+ msgstr ""
163
+
164
+ #: /home/szaleq/easy-watermark/trunk/easy-watermark.php:224
165
+ msgid "Be carefull with that option. If some images alredy has watermark, it will be added though."
166
+ msgstr ""
167
+
168
+ #: /home/szaleq/easy-watermark/trunk/easy-watermark-settings.php:116
169
+ msgid "Settings"
170
+ msgstr ""
171
+
readme.txt ADDED
@@ -0,0 +1,51 @@
1
+ === Easy Watermark ===
2
+ Contributors: szaleq
3
+ Tags: watermark, image, picture, photo, media, gallery, signature, transparent, upload, admin
4
+ Requires at least: 3.3
5
+ Tested up to: 3.5.1
6
+ Stable tag: 0.1
7
+ License: GPLv2 or later
8
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
+
10
+ Automatically adds watermark to images when they are uploaded to the WordPress Media Library.
11
+
12
+ == Description ==
13
+
14
+ This plugin allows you to add image watermark to every single image or all images from library at once. It can also be configured to automatically watermark new images as they are uploaded. Watermark can be a png, gif (alpha channel supported in both cases) or jpg image. It's also possibile to set watermark opacity (doesn't apply to png with alpha channel).
15
+
16
+ The possibility of adding text watermark as well as defining many watermarks is in nearest plans. Check for updates.
17
+
18
+ Please, contact me if you have any questions/ideas or issues.
19
+
20
+ == Installation ==
21
+
22
+ Note: Easy Watermark requires GD extension installed and enabled on the server to work correctly.
23
+
24
+ 1. Unpack easy-watermark.zip and upload its content to the `/wp-content/plugins/` directory
25
+ 1. Activate the plugin through the 'Plugins' menu in WordPress
26
+ 1. Plugin is working. Go to "Settings > Easy Watermark Settings" to set up your watermark.
27
+
28
+ == Frequently asked questions ==
29
+
30
+ = Can I remove watermark after it was added? =
31
+ Unfortunately, not yet. Keeping oryginal pictures feature is in plans, so it will be possibile to restore original image in the future.
32
+
33
+ = How can I add watermark to pictures that were uploaded before the plugin was installed? =
34
+ You can go to "Media >> Easy Watermark" and click "Add watermark to all images" button. If you wont to add watermark to single images, you can find links titled "Add watermark" in the media library (see screenshots) or "Add watermark" button on image edit page.
35
+
36
+ = How can I adjust watermark position? =
37
+ Watermark position can be adjusted vertically and horizontally by selecting alignment (left, center, right, top, middle, bottom). You can also define horizontal and vertical offset, for example if vertical alignment is set to bottom with offset 100 and horizontal alignment is right with offset 200, watermark will show up 100px from lower edge and 200px from right edge of the picture.
38
+
39
+
40
+ If you have any other questions, please contact me.
41
+
42
+ == Screenshots ==
43
+
44
+ 1. Settings page
45
+ 2. Easy Watermark Tool
46
+ 3. "Add Watermark" link in media library
47
+
48
+ == Changelog ==
49
+
50
+ = 0.1 =
51
+ * Initial release
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file
screenshot-3.png ADDED
Binary file
settings-form.php ADDED
@@ -0,0 +1,69 @@
1
+ <?php
2
+ $auto_add = $options['auto_add'];
3
+ $image_types = $options['image_types'];
4
+ ?>
5
+ <div class="wrap easy-watermark">
6
+ <h2><?php _e('Easy Watermark Settings', 'easy-watermark'); ?></h2><a href="<?php echo admin_url('/upload.php?page=easy-watermark'); ?>"><?php _e('Go to Easy Watermark Tool', 'easy-watermark'); ?></a>
7
+ <form method="post" action="options.php" id="easy-watermark-settings-form">
8
+ <?php settings_fields('easy-watermark-settings'); ?>
9
+ <h3><?php _e('General settings', 'easy-watermark'); ?></h3>
10
+ <table class="form-table">
11
+ <tr valign="top"><th scope="row"><?php _e('Auto watermark', 'easy-watermark'); ?></th>
12
+ <td><label for="easy-watermark-autoadd"><input id="easy-watermark-autoadd" name="easy-watermark-settings[auto_add]" type="checkbox" value="1" <?php checked('1', $auto_add); ?> /> <?php _e('Add watermark when uploading images', 'easy-watermark'); ?></label></td>
13
+ </tr>
14
+ <tr valign="top" class="auto-add-options" style="display:none;"><th scope="row"><?php _e('Image types', 'easy-watermark'); ?></th>
15
+ <td>
16
+ <label for="image-type-jpg"><input id="image-type-jpg" type="checkbox" name="easy-watermark-settings[image_types][jpeg]" value="jpeg" <?php checked('1', isset($image_types['jpeg'])); ?> /> jpeg</label><br/></fieldset>
17
+ <label for="image-type-png"><input id="image-type-png" type="checkbox" name="easy-watermark-settings[image_types][png]" value="png" <?php checked('1', isset($image_types['png'])); ?> /> png</label><br/>
18
+ <label for="image-type-gif"><input id="image-type-gif" type="checkbox" name="easy-watermark-settings[image_types][gif]" value="gif" <?php checked('1', isset($image_types['gif'])); ?> /> gif</label><p class="description"><?php _e('Select image types which should be watermarked', 'easy-watermark'); ?></p></td>
19
+ </tr>
20
+ </table>
21
+ <h3><?php _e('Watermark settings', 'easy-watermark'); ?></h3>
22
+ <table class="form-table">
23
+ <tr valign="top"><th scope="row"><label for="easy-watermark-url"><?php _e('Watermark image', 'easy-watermark'); ?></label></th>
24
+ <td><input id="easy-watermark-url" class="regular-text" name="easy-watermark-settings[image][url]" type="hidden" value="<?php echo $options['image']['url']; ?>" /><input id="easy-watermark-id" name="easy-watermark-settings[image][id]" type="hidden" value="<?php echo $options['image']['id']; ?>" /><input id="easy-watermark-mime" name="easy-watermark-settings[image][mime]" type="hidden" value="<?php echo $options['image']['mime']; ?>" />
25
+ <?php
26
+ $modal_update_href = esc_url( add_query_arg( array(
27
+ 'page' => 'easy-watermark',
28
+ '_wpnonce' => wp_create_nonce('easy-watermark'),
29
+ ), admin_url('upload.php') ) );
30
+ if(empty($options['image']['url'])) :
31
+ ?>
32
+ <a class="button-secondary" id="select-image-button" data-choose="<?php _e('Choose Watermark Image', 'easy-watermark'); ?>" data-button-label="<?php _e('Set as Watermark Image', 'easy-watermark'); ?>" href="#"><?php _e('Select/Upload Image', 'easy-watermark'); ?></a>
33
+ <br/>
34
+ <input id="easy-watermark-position-vert" name="easy-watermark-settings[image][position-vert]" type="hidden" value="<?php echo $options['image']['position-vert']; ?>" />
35
+ <input id="easy-watermark-position-horizontal" name="easy-watermark-settings[image][position-horizontal]" type="hidden" value="<?php echo $options['image']['position-horizontal']; ?>" />
36
+ <input id="easy-watermark-position-vert" name="easy-watermark-settings[image][offset-vert]" type="hidden" value="<?php echo $options['image']['offset-vert']; ?>" />
37
+ <input id="easy-watermark-position-horizontal" name="easy-watermark-settings[image][offset-horizontal]" type="hidden" value="<?php echo $options['image']['offset-horizontal']; ?>" />
38
+ <input id="easy-watermark-alpha" name="easy-watermark-settings[image][alpha]" type="hidden" value="<?php echo $options['image']['alpha']; ?>" />
39
+ <?php else : ?>
40
+ <img id="watermark-preview" style="max-height:200px;width:auto;cursor:pointer;" src="<?php echo $options['image']['url']; ?>" /><span style="display:none;" id="loading-preview"><?php _e('Loading preview...', 'easy-watermark'); ?></span>
41
+ <p class="description"><?php _e('Click on image to change it.', 'easy-watermark'); ?> <a href="#" class="remove-image"><?php _e('Remove image', 'easy-watermark'); ?></a></p>
42
+ <p class="description"><?php _e('Note: if "Auto watermark" option is ticked, untick it before uploading new watermark image or remove current image first.', 'easy-watermark'); ?></p>
43
+ </td>
44
+ </tr>
45
+
46
+ <tr valign="top" class="watermark-options"><th scope="row"><?php _e('Watermark position', 'easy-watermark'); ?></th>
47
+ <td><strong> <?php _e('vertical', 'easy-watermark'); ?>: </strong>
48
+ <label for="easy-watermark-position-top"><input id="easy-watermark-position-top" name="easy-watermark-settings[image][position-vert]" type="radio" value="top" <?php echo $options['image']['position-vert'] == 'top' ? 'checked' : null; ?>/> <?php _e('top', 'easy-watermark'); ?></label>
49
+ <label for="easy-watermark-position-mdl"><input id="easy-watermark-position-mdl" name="easy-watermark-settings[image][position-vert]" type="radio" value="mdl" <?php echo $options['image']['position-vert'] == 'mdl' ? 'checked' : null; ?> /> <?php _e('middle', 'easy-watermark'); ?></label>
50
+ <label for="easy-watermark-position-btm"><input id="easy-watermark-position-btm" name="easy-watermark-settings[image][position-vert]" type="radio" value="btm" <?php echo $options['image']['position-vert'] == 'btm' ? 'checked' : null; ?> /> <?php _e('bottom', 'easy-watermark'); ?></label><br />
51
+ <label for="easy-watermark-position-offset-vert"> <?php _e('offset', 'easy-watermark'); ?>: </label>
52
+ <input style="width:60px;" type="text" id="easy-watermark-position-offset-vert" name="easy-watermark-settings[image][offset-vert]" value="<?php echo $options['image']['offset-vert']; ?>" /> px<br /><br /><strong> <?php _e('horizontal', 'easy-watermark'); ?>: </strong>
53
+ <label for="easy-watermark-position-lft"><input id="easy-watermark-position-lft" name="easy-watermark-settings[image][position-horizontal]" type="radio" value="lft" <?php echo $options['image']['position-horizontal'] == 'lft' ? 'checked' : null; ?>/> <?php _e('left', 'easy-watermark'); ?></label>
54
+ <label for="easy-watermark-position-ctr"><input id="easy-watermark-position-ctr" name="easy-watermark-settings[image][position-horizontal]" type="radio" value="ctr" <?php echo $options['image']['position-horizontal'] == 'ctr' ? 'checked' : null; ?> /> <?php _e('center', 'easy-watermark'); ?></label>
55
+ <label for="easy-watermark-position-rgt"><input id="easy-watermark-position-rgt" name="easy-watermark-settings[image][position-horizontal]" type="radio" value="rgt" <?php echo $options['image']['position-horizontal'] == 'rgt' ? 'checked' : null; ?> /> <?php _e('right', 'easy-watermark'); ?></label><br />
56
+ <label for="easy-watermark-position-offset-vert">offset: </label>
57
+ <input type="text" style="width:60px;" id="easy-watermark-position-offset-horizontal" name="easy-watermark-settings[image][offset-horizontal]" value="<?php echo $options['image']['offset-horizontal']; ?>"/> px
58
+ </td>
59
+ </tr>
60
+ <tr valign="top" class="watermark-options"><th scope="row"><?php _e('Opacity', 'easy-watermark'); ?></th><td><input id="easy-watermark-alpha" name="easy-watermark-settings[image][alpha]" style="width:60px;" type="text" value="<?php echo $options['image']['alpha']; ?>" /> %<p class="description"><?php _e('Opacity does not affect the png images with alpha chanel.', 'easy-watermark'); ?></p>
61
+ <?php endif; ?>
62
+ </td>
63
+ </tr>
64
+ </table>
65
+ <p class="submit">
66
+ <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
67
+ </p>
68
+ </form>
69
+ </div>