-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcache-images.php
577 lines (500 loc) · 21.6 KB
/
cache-images.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
<?php
/*
Plugin Name: Cache Images
Plugin URI: http://wordpress.org/extend/plugins/cache-images/
Description: Goes through your posts and gives you the option to cache all hotlinked images from a domain locally in your upload folder
Version: 3.1
Author: Matt Mullenweg
Author URI: http://ma.tt/
WordPress Version Required: 2.8
*/
/**
* If file is opened directly, return 403 error
*/
if (!function_exists ('add_action')) {
header('Status: 403 Forbidden');
header('HTTP/1.1 403 Forbidden');
exit();
}
/**
* Yes, we're localizing the plugin. This partly makes sure non-English
* users can use it too. To translate into your language use the
* cache-images.pot file in /languages folder. Poedit is a good tool to for translating.
* @link http://poedit.net
*
*/
function cache_images_init() {
load_plugin_textdomain( 'cache-images', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}
add_action( 'init', 'cache_images_init' );
/**
* Add action links to plugins page
* Thanks Dion Hulse
* @link http://dd32.id.au/wordpress-plugins/?configure-link
* (taken from Adminize plugin)
*/
function cache_images_filter_plugin_actions($links, $file){
static $this_plugin;
if( !$this_plugin ) $this_plugin = plugin_basename(__FILE__);
if( $file == $this_plugin ){
$settings_link = '<a href="' . admin_url('options-media.php') . '#cache_images_automatic_caching' . '">' . __('Settings', 'cache-images') . '</a>';
$scaning_link = '<a href="' . admin_url('tools.php?page=cache-images/cache-images.php') . '">' . __('Scanning', 'cache-images') . '</a>';
$links = array_merge( array($settings_link, $scaning_link), $links); // before other links
}
return $links;
}
add_filter( 'plugin_action_links', 'cache_images_filter_plugin_actions', 10, 2 );
/**
* Search a multiple array
* @link http://www.php.net/manual/en/function.in-array.php#20594
*/
function in_multi_array($needle, $haystack)
{
$in_multi_array = false;
if(in_array($needle, $haystack))
{
$in_multi_array = true;
}
else
{
for($i = 0; $i < sizeof($haystack); $i++)
{
if(is_array($haystack[$i]))
{
if(in_multi_array($needle, $haystack[$i]))
{
$in_multi_array = true;
break;
}
}
}
}
return $in_multi_array;
}
/**
* Add Cache Images page under Tools
*/
function mm_ci_add_pages() {
add_management_page( __( 'Cache Remote Images', 'cache-images' ), __( 'Cache Remote Images', 'cache-images' ), 8, __FILE__,
'mm_ci_manage_page' );
}
function mm_ci_manage_page() {
global $wpdb;
?>
<div class="wrap">
<h2><?php _e( 'Remote Image Caching', 'cache-images' ); ?></h2>
<p><?php _e( 'Here’s how this works:', 'cache-images' ); ?></p>
<ol>
<li><?php _e( 'Click the button below and we’ll scan all of your posts for remote images', 'cache-images' ); ?> (<em><?php _e( 'Button <strong>Scan</strong> will search only for images that are hotlinked (ie. used like in example <code><img src="http://example.com/picture.jpg" /></code>), while button <strong>Scan (including linked)</strong> will search for images that are only linked from this site (ie. ised like in example <code><a href="http://example.com/picture.jpg">example</a></code>). Use second button with caution!', 'cache-images' ); ?></em>)</li>
<li><?php _e( 'Then you’ll be presented with a list of domains. For each domain, press button Cache from this domain', 'cache-images' ); ?></li>
<li><?php _e( 'The images will be copied to your upload directory, the links in your posts will be updated to the new location, and images will be added to your media library, associated to first post from where they are found.', 'cache-images' ); ?></li>
</ol>
<?php
/**
* Show notice for WP Smush.it
*/
if ( !function_exists( 'wp_smushit' ) ) {
?><div class="wp-smushit-notice error">
<strong><?php _e( "Tip:", "gse_textdomain" );?></strong><br />
<?php _e( "You can install plugin WP Smush.it to reduce image file sizes and improve performance using the Smush.it API.", "cache-images" );
echo sprintf(__( " (<a href='%s'>read more about WP Smush.it</a>)", "cache-images" ), "http://dialect.ca/code/wp-smushit/" );?><br />
<?php echo sprintf(__( "<a href='%s' class='thickbox'>Install WP Smush.it</a>", "cache-images" ), esc_url(admin_url( 'plugin-install.php?tab=plugin-information&plugin=wp-smushit&TB_iframe=true&width=600&height=550' )));?><br />
</div>
<?php }
?>
<script type="text/javascript">
function getdomains() {
jQuery.ajax({
url: ajaxurl,
type: "POST",
//contentType: "application/json",
data: "action=cache_images&do=getdomains",
success: function(result) {
if (result === 'null') {
setStatusMessage('<?php _e( 'No posts with images were found.', 'cache-images' ); ?>');
return;
}
var list = eval(result);
var curr = 0;
setStatusMessage('<?php _e( 'We found some results. Choose the domains from where you want to grab images from by clicking on a button "Cache from this domain" next to it.', 'cache-images' ); echo '<br />'; _e( '<strong>Note</strong>: you <strong>must not close</strong> this page while caching is performed. You can close it when you see message "Done caching from..." and yellow bar is removed', 'cache-images' ); ?>');
function domainList() {
if (curr >= list.length) {
return;
}
jQuery("#listofdomains").after("<li id=\"domain_" + list[curr].domainmd5 + "\"><label><code>" + list[curr].domain + "</code> (<?php printf(__( 'results: %1$s', 'cache-images' ), '" + list[curr].num + "'); ?>) <input type=\"button\" onClick=\"javascript:regenerate('" + list[curr].domain + "\', \'" + list[curr].domainmd5 + "\');\" class=\"button\" name=\"cache_images_" + list[curr].domainmd5 + "\" id=\"cache_images_" + list[curr].domainmd5 + "\" value=\"<?php _e( 'Cache from this domain', 'cache-images' ) ?>\" /> </label></li>");
curr = curr + 1;
domainList();
}
domainList();
},
error: function(request, status, error) {
var errormessageone = "<?php _e( 'Error %1$s', 'cache-images' ); ?>";
var errormessage = errormessageone.replace("%1$s", request.status);
setMessage(errormessage);
}
});
}
</script>
<script type="text/javascript">
function getalldomains() {
jQuery.ajax({
url: ajaxurl,
type: "POST",
//contentType: "application/json",
data: "action=cache_images&do=getalldomains",
success: function(result) {
if (result === 'null') {
setStatusMessage('<?php _e( 'No posts with images were found.', 'cache-images' ); ?>');
return;
}
var list = eval(result);
var curr = 0;
setStatusMessage('<?php _e( 'We found some results. Choose the domains from where you want to grab images from by clicking on a button "Cache from this domain" next to it.', 'cache-images' ); echo '<br />'; _e( '<strong>Note</strong>: you <strong>must not close</strong> this page while caching is performed. You can close it when you see message "Done caching from..." and yellow bar is removed', 'cache-images' ); ?>');
function allDomainList() {
if (curr >= list.length) {
return;
}
jQuery("#listofdomains").after("<li id=\"domain_" + list[curr].domainmd5 + "\"><label><code>" + list[curr].domain + "</code> (<?php printf(__( 'results: %1$s', 'cache-images' ), '" + list[curr].num + "'); ?>) <input type=\"button\" onClick=\"javascript:cacheall('" + list[curr].domain + "\', \'" + list[curr].domainmd5 + "\');\" class=\"button\" name=\"cache_images_" + list[curr].domainmd5 + "\" id=\"cache_images_" + list[curr].domainmd5 + "\" value=\"<?php _e( 'Cache from this domain', 'cache-images' ) ?>\" /> </label></li>");
curr = curr + 1;
allDomainList();
}
allDomainList();
},
error: function(request, status, error) {
var errormessageone = "<?php _e( 'Error %1$s', 'cache-images' ); ?>";
var errormessage = errormessageone.replace("%1$s", request.status);
setMessage(errormessage);
}
});
}
</script>
<script type="text/javascript">
function setMessage(msg) {
jQuery("#message").html(msg);
jQuery("#message").show();
}
function setStatusMessage(msg) {
jQuery("#status-message").html(msg);
jQuery("#status-message").show();
}
function regenerate(domain,domainmd5) {
jQuery("#cache_images_" + domainmd5).attr("disabled", true);
setMessage("<?php _e( 'Reading posts...', 'cache-images' ); ?>");
jQuery.ajax({
url: ajaxurl,
type: "POST",
//contentType: "application/json",
data: "action=cache_images&do=getlist&domain=" + domain,
success: function(result) {
var list = eval(result);
var curr = 0;
function regenItem() {
if (curr >= list.length) {
jQuery("#cache_images_" + domainmd5).removeAttr("disabled");
jQuery("#thumb").hide();
jQuery("#domain_" + domainmd5).hide();
var donecachingone = "<?php _e( 'Done caching from %1$s', 'cache-images' ); ?>";
var donecaching = donecachingone.replace("%1$s", domain);
setMessage(donecaching);
jQuery("#message").fadeOut(1300);
return;
}
var cachestatusone = "<?php _e( 'Caching %1$s of %2$s', 'cache-images' ); ?>";
var cachestatustwo = cachestatusone.replace("%1$s", curr+1);
var cachestatus = cachestatustwo.replace("%2$s", list.length);
setMessage(cachestatus);
jQuery.ajax({
url: ajaxurl,
type: "POST",
data: "action=cache_images&do=regen&url=" + list[curr].url + "&postid=" + list[curr].postid,
success: function(result) {
jQuery("#thumb").show();
jQuery("#thumb-img").html(result);
curr = curr + 1;
regenItem();
}
});
}
regenItem();
},
error: function(request, status, error) {
var errormessageone = "<?php _e( 'Error %1$s', 'cache-images' ); ?>";
var errormessage = errormessageone.replace("%1$s", request.status);
setMessage(errormessage);
}
});
}
function cacheall(domain,domainmd5) {
jQuery("#cache_images_" + domainmd5).attr("disabled", true);
setMessage("<?php _e( 'Reading posts...', 'cache-images' ); ?>");
jQuery.ajax({
url: ajaxurl,
type: "POST",
//contentType: "application/json",
data: "action=cache_images&do=getalllist&domain=" + domain,
success: function(result) {
var list = eval(result);
var curr = 0;
function regenItem() {
if (curr >= list.length) {
jQuery("#cache_images_" + domainmd5).removeAttr("disabled");
jQuery("#thumb").hide();
jQuery("#domain_" + domainmd5).hide();
var donecachingone = "<?php _e( 'Done caching from %1$s', 'cache-images' ); ?>";
var donecaching = donecachingone.replace("%1$s", domain);
setMessage(donecaching);
jQuery("#message").fadeOut(1300);
return;
}
var cachestatusone = "<?php _e( 'Caching %1$s of %2$s', 'cache-images' ); ?>";
var cachestatustwo = cachestatusone.replace("%1$s", curr+1);
var cachestatus = cachestatustwo.replace("%2$s", list.length);
setMessage(cachestatus);
jQuery.ajax({
url: ajaxurl,
type: "POST",
data: "action=cache_images&do=regen&url=" + list[curr].url + "&postid=" + list[curr].postid,
success: function(result) {
jQuery("#thumb").show();
jQuery("#thumb-img").html(result);
curr = curr + 1;
regenItem();
}
});
}
regenItem();
},
error: function(request, status, error) {
var errormessageone = "<?php _e( 'Error %1$s', 'cache-images' ); ?>";
var errormessage = errormessageone.replace("%1$s", request.status);
setMessage(errormessage);
}
});
}
function showexplanation() {
jQuery("#explain-all-domains").show();
}
</script>
<div id="status-message" class="updated fade" style="display:none"></div>
<form action="" method="post">
<p class="submit">
<input name="step" type="hidden" id="step" value="2">
<input type="button" onClick="javascript:getdomains();" class="button" name="Submit" value="<?php _e( 'Scan »', 'cache-images' ); ?>" />
<input type="button" onClick="javascript:getalldomains();" class="button" name="Submit" style="margin-left: 200px;" value="<?php _e( 'Scan (including linked) »', 'cache-images' ); ?>" /> (<a onClick="javascript:showexplanation();" href="#"><?php _e( 'what is difference?', 'cache-images' ); ?></a>)
<div id="explain-all-domains" class="notice" style="display:none"><?php _e( 'Button <strong>Scan</strong> will search only for images that are hotlinked (ie. used like in example <code><img src="http://example.com/picture.jpg" /></code>), while button <strong>Scan (including linked)</strong> will search for images that are only linked from this site (ie. ised like in example <code><a href="http://example.com/picture.jpg">example</a></code>). Use second button with caution!', 'cache-images' ); ?></div>
</p>
<ul>
<li id="listofdomains"></li>
</ul>
</form>
<div id="message" class="updated fade" style="display:none"></div>
<div id="thumb" style="display:none"><?php printf( __( 'Last cached picture: %1$s', 'cache-images' ), '<span id="thumb-img"></span>' ); ?></div>
</div>
<?php
}
add_action('admin_menu', 'mm_ci_add_pages');
/**
* Handle AJAX requests
*/
function cache_images_ajax() {
global $wpdb;
$action = $_POST["do"];
if ($action == "getlist") {
$domain = $_POST["domain"];
$postid_list = $wpdb->get_results("SELECT DISTINCT ID FROM $wpdb->posts WHERE post_content LIKE ('%<img%') AND post_content LIKE ('%$domain%')");
foreach ( $postid_list as $v ) {
$postid = $v->ID;
$post = $wpdb->get_results("SELECT post_content FROM $wpdb->posts WHERE ID = '$postid'");
preg_match_all('|<img.*?src=[\'"](.*?)[\'"].*?>|i', $post[0]->post_content, $matches);
foreach ( $matches[1] as $url ) :
if ( strstr( $url, get_option('siteurl') . '/' . get_option('upload_path') ) || !strstr( $url, $domain) || (($res) && in_multi_array($url, $res)))
continue; // Already local
// got tip from http://www.devcomments.com/Plus-signs-in-url-replaced-with-space-in-GET-at49448.htm
$origurl = $url;
$url = urlencode($url);
$res[] = array('url' => $url, 'postid' => $postid, 'origurl' => $origurl);
endforeach;
}
die( json_encode($res) );
} else if ($action == "getalllist") {
$domain = $_POST["domain"];
$postid_list = $wpdb->get_results("SELECT DISTINCT ID FROM $wpdb->posts WHERE post_content LIKE ('%$domain%')");
foreach ( $postid_list as $v ) {
$postid = $v->ID;
$post = $wpdb->get_results("SELECT post_content FROM $wpdb->posts WHERE ID = '$postid'");
preg_match_all('#(http://[^\s]+(?=\.(jpe?g|png|gif)))#i', $post[0]->post_content, $matches);
foreach ( $matches[1] as $url ) :
if ( strstr( $post[0]->post_content, $url . '.jpg' ) ) {
$url = $url . '.jpg';
} else if ( strstr( $post[0]->post_content, $url . '.jpeg' ) ) {
$url = $url . '.jpeg';
} else if ( strstr( $post[0]->post_content, $url . '.png' ) ) {
$url = $url . '.png';
} else if ( strstr( $post[0]->post_content, $url . '.gif' ) ) {
$url = $url . '.gif';
}
if ( strstr( $url, get_option('siteurl') . '/' . get_option('upload_path') ) || !strstr( $url, $domain) || (($res) && in_multi_array($url, $res)))
continue; // Already local
$origurl = $url;
$url = urlencode($url);
$res[] = array('url' => $url, 'postid' => $postid, 'origurl' => $origurl);
endforeach;
}
die( json_encode($res) );
} else if ($action == "regen") {
$url = $_POST["url"];
$postid = $_POST["postid"];
$url = cache_images_cache_image($url, $postid);
die( $url );
} else if ($action == "getdomains") {
$posts = $wpdb->get_results("SELECT post_content FROM $wpdb->posts WHERE post_content LIKE ('%<img%') AND post_status LIKE ('%publish%') OR post_status LIKE ('%draft%')");
if ( !$posts )
die( __( "No posts with images were found.", "cache-images" ) );
foreach ($posts as $post) :
$domains = cache_images_find_images($post->post_content, $domains);
endforeach;
$local_domain = parse_url( get_option( 'siteurl' ) );
foreach ($domains as $domain => $num) :
if ( strstr( $domain, $local_domain['host'] ) )
continue; // Already local
$domain_md5 = md5( $domain );
$res[] = array('domain' => $domain, 'num' => $num, 'domainmd5' => $domain_md5);
endforeach;
die( json_encode($res) );
} else if ($action == "getalldomains") {
$posts = $wpdb->get_results("SELECT post_content FROM $wpdb->posts WHERE post_content LIKE ('%<a%') AND post_status LIKE ('%publish%') OR post_status LIKE ('%draft%')");
if ( !$posts )
die( __( "No posts with images were found.", "cache-images" ) );
foreach ($posts as $post) :
$domains = cache_images_find_all_images($post->post_content, $domains);
endforeach;
$local_domain = parse_url( get_option( 'siteurl' ) );
foreach ($domains as $domain => $num) :
if ( strstr( $domain, $local_domain['host'] ) )
continue; // Already local
$domain_md5 = md5( $domain );
$res[] = array('domain' => $domain, 'num' => $num, 'domainmd5' => $domain_md5);
endforeach;
if ( !$res )
die( __( "No posts with images were found.", "cache-images" ) );
die( json_encode($res) );
}
}
add_action('wp_ajax_cache_images', 'cache_images_ajax');
/**
* Find hotlinked external images in provided content
*/
function cache_images_find_images($content, $domains) {
preg_match_all('|<img.*?src=[\'"](.*?)[\'"].*?>|i', $content, $matches);
foreach ($matches[1] as $url) :
$url = parse_url($url);
$domains[$url['host']]++;
endforeach;
return $domains;
}
/**
* Find all external images in provided content
* Regex by BDuelz on StackOverflow
* @link http://stackoverflow.com/questions/3371902/php-regex-get-image-from-url/3372785#3372785
*/
function cache_images_find_all_images($content, $domains) {
preg_match_all('#(http://[^\s]+(?=\.(jpe?g|png|gif)))#i', $content, $matches);
foreach ($matches[1] as $url) :
$url = parse_url($url);
$domains[$url['host']]++;
endforeach;
return $domains;
}
/**
* Cache image from provided URL
*
* Add image to media library and
* replace all occurences of it
*/
function cache_images_cache_image($url, $postid) {
global $wpdb;
$orig_url = $url;
//check if pic is on Blogger
if (strpos($url, 'blogspot.com') || strpos($url, 'blogger.com') || strpos($url, 'ggpht.com') || strpos($url, 'googleusercontent.com') || strpos($url, 'gstatic.com')) {
$response = wp_remote_request($url);
if ( is_wp_error( $response ) )
return 'error1';
$my_body = wp_remote_retrieve_body($response);
if (strpos($my_body, 'src')) {
preg_match_all('|<img.*?src=[\'"](.*?)[\'"].*?>|i', $my_body, $matches);
foreach ( $matches[1] as $url ) :
$spisak = $url;
endforeach;
$url = $spisak;
}
}
set_time_limit( 300 );
require_once( ABSPATH . 'wp-admin/includes/media.php' );
require_once( ABSPATH . 'wp-admin/includes/file.php' );
$upload = media_sideload_image($url, $postid);
if ( !is_wp_error($upload) ) {
preg_match_all('|<img.*?src=[\'"](.*?)[\'"].*?>|i', $upload, $locals);
foreach ( $locals[1] as $newurl ) :
$wpdb->query("UPDATE $wpdb->posts SET post_content = REPLACE(post_content, '$orig_url', '$newurl');");
endforeach;
}
return $url;
}
/**
* Cache images on post's saving
*/
function cache_images_save_post($post_ID, $post) {
global $wpdb;
$cache_images_settings = get_option( 'cache_images_automatic_caching' );
if ( $cache_images_settings && $cache_images_settings == 1 ) {
if ( wp_is_post_autosave($post_ID) || wp_is_post_revision($post_ID) )
return $post_ID;
$domains = cache_images_find_images($post->post_content, $domains);
if ( !$domains )
return $post_ID;
$local_domain = parse_url( get_option( 'siteurl' ) );
foreach ($domains as $domain => $num) :
if ( strstr( $domain, $local_domain['host'] ) )
continue; // Already local
preg_match_all('|<img.*?src=[\'"](.*?)[\'"].*?>|i', $post->post_content, $matches);
foreach ( $matches[1] as $url ) :
if ( strstr( $url, get_option('siteurl') . '/' . get_option('upload_path') ) || !strstr( $url, $domain) || (($res) && in_multi_array($url, $res)))
continue; // Already local
cache_images_cache_image($url, $post_ID);
endforeach;
endforeach;
return $post_ID;
}
return $post_ID;
}
add_action( 'save_post', 'cache_images_save_post', 10, 2 );
/**
* Add section & field on Media Settings page
* @link http://planetozh.com/blog/2009/05/handling-plugins-options-in-wordpress-28-with-register_setting/
* @link http://ottopress.com/2009/wordpress-settings-api-tutorial/
*/
function cache_images_add_settings_field() {
add_settings_section( 'cache_images_settings_section', __( 'Cache Images', 'cache-images' ), 'cache_images_section_callback', 'media' );
add_settings_field( 'cache_images_automatic_caching' , __( 'Automatic caching', 'cache-images' ) , 'cache_images_field_settings_form' , 'media' , 'cache_images_settings_section' );
register_setting( 'media', 'cache_images_automatic_caching' );
}
function cache_images_section_callback() {
}
/**
* Print field on Media Settings page
* @link http://planetozh.com/blog/2009/05/handling-plugins-options-in-wordpress-28-with-register_setting/
* @link http://ottopress.com/2009/wordpress-settings-api-tutorial/
*/
function cache_images_field_settings_form() {
?>
<label><input name="cache_images_automatic_caching" id="cache_images_automatic_caching" type="checkbox" value="1"
<?php checked( '1', get_option( 'cache_images_automatic_caching' ) ); ?> /> <?php _e( 'Automatically cache images on post’s saving', 'cache-images' ); ?> </label>
<?php
}
add_action( 'admin_init', 'cache_images_add_settings_field' );
/*
to do:
if pic from Blogger has + in it, how to handle it
cache only on page where is found
*/
?>