Version Description
- Delete all custom image sizes when regenerate thumbnails
- Notifies you when thumbnails was deleted
Download this release
Release Info
Developer | Pedro Elsner |
Plugin | Force Regenerate Thumbnails |
Version | 1.1 |
Comparing to | |
See all releases |
Code changes from version 1.0 to 1.1
- force-regenerate-thumbnails.php +32 -11
- readme.txt +7 -5
force-regenerate-thumbnails.php
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
/*
|
3 |
Plugin Name: Force Regenerate Thumbnails
|
4 |
Plugin URI: http://pedroelsner.com/2012/08/forcando-a-atualizacao-de-thumbnails-no-wordpress
|
5 |
-
Description:
|
6 |
-
Version: 1.
|
7 |
Author: Pedro Elsner
|
8 |
Author URI: http://www.pedroelsner.com/
|
9 |
*/
|
@@ -426,21 +426,43 @@ class ForceRegenerateThumbnails {
|
|
426 |
@set_time_limit(900);
|
427 |
|
428 |
|
|
|
429 |
/**
|
430 |
-
*
|
431 |
-
*
|
432 |
*/
|
433 |
-
global $_wp_additional_image_sizes;
|
434 |
$message = '';
|
435 |
$imagePath = substr($fullsizepath, 0, strlen($fullsizepath) - 4);
|
436 |
$imageFormat = substr($fullsizepath, -4);
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
441 |
}
|
442 |
|
443 |
|
|
|
|
|
|
|
444 |
$metadata = wp_generate_attachment_metadata($image->ID, $fullsizepath);
|
445 |
|
446 |
if (is_wp_error($metadata)) {
|
@@ -454,9 +476,8 @@ class ForceRegenerateThumbnails {
|
|
454 |
}
|
455 |
|
456 |
wp_update_attachment_metadata($image->ID, $metadata);
|
457 |
-
$message = sprintf(__('<b>"%1$s" (ID %2$s): All thumbnails was successfully regenerated in %3$s seconds.</b>', 'force-regenerate-thumbnails') . $regenerate_status, esc_html(get_the_title($image->ID)), $image->ID, timer_stop()) . $message;
|
458 |
-
//die(json_encode(array('success' => sprintf(__('"%1$s" (ID %2$s) was all thumbnails successfully regenereted in %3$s seconds.', 'force-regenerate-thumbnails') . $regenerate_status, esc_html(get_the_title($image->ID)), $image->ID, timer_stop()))));
|
459 |
|
|
|
460 |
die(json_encode(array('success' => $message)));
|
461 |
}
|
462 |
|
2 |
/*
|
3 |
Plugin Name: Force Regenerate Thumbnails
|
4 |
Plugin URI: http://pedroelsner.com/2012/08/forcando-a-atualizacao-de-thumbnails-no-wordpress
|
5 |
+
Description: Delete and REALLY force the regenerate thumbnail. Based in plugin: Regenerate Thumbnails - All credits and thanks to Viper007Bond
|
6 |
+
Version: 1.1
|
7 |
Author: Pedro Elsner
|
8 |
Author URI: http://www.pedroelsner.com/
|
9 |
*/
|
426 |
@set_time_limit(900);
|
427 |
|
428 |
|
429 |
+
|
430 |
/**
|
431 |
+
* Grant image deleted
|
432 |
+
* @since 1.1
|
433 |
*/
|
|
|
434 |
$message = '';
|
435 |
$imagePath = substr($fullsizepath, 0, strlen($fullsizepath) - 4);
|
436 |
$imageFormat = substr($fullsizepath, -4);
|
437 |
+
$dirPath = explode(DIRECTORY_SEPARATOR, $imagePath);
|
438 |
+
$imageName = sprintf("%s-", $dirPath[count($dirPath)-1]);
|
439 |
+
unset($dirPath[count($dirPath)-1]);
|
440 |
+
$dirPath = sprintf("%s%s", implode(DIRECTORY_SEPARATOR, $dirPath), DIRECTORY_SEPARATOR);
|
441 |
+
|
442 |
+
// Read and delete files
|
443 |
+
$dir = opendir($dirPath);
|
444 |
+
$files = array();
|
445 |
+
while ($file = readdir($dir)) {
|
446 |
+
if (!(strrpos($file, $imageName) === false)) {
|
447 |
+
$thumbnail = explode($imageName, $file);
|
448 |
+
if ($thumbnail[0] == "") {
|
449 |
+
$thumbnailFormat = substr($thumbnail[1], -4);
|
450 |
+
$thumbnail = substr($thumbnail[1], 0, strlen($thumbnail[1]) - 4);
|
451 |
+
$thumbnail = explode('x', $thumbnail);
|
452 |
+
if (count($thumbnail) == 2) {
|
453 |
+
if (is_numeric($thumbnail[0]) && is_numeric($thumbnail[1])) {
|
454 |
+
$message .= sprintf('<br /> - ' . __("Thumbnail: %sx%s was deleted.", 'force-regenerate-thumbnails'), $thumbnail[0], $thumbnail[1]);
|
455 |
+
@unlink($dirPath . $imageName . $thumbnail[0] . 'x' . $thumbnail[1] . $thumbnailFormat);
|
456 |
+
}
|
457 |
+
}
|
458 |
+
}
|
459 |
+
}
|
460 |
}
|
461 |
|
462 |
|
463 |
+
/**
|
464 |
+
* Regenerate
|
465 |
+
*/
|
466 |
$metadata = wp_generate_attachment_metadata($image->ID, $fullsizepath);
|
467 |
|
468 |
if (is_wp_error($metadata)) {
|
476 |
}
|
477 |
|
478 |
wp_update_attachment_metadata($image->ID, $metadata);
|
|
|
|
|
479 |
|
480 |
+
$message = sprintf(__('<b>"%1$s" (ID %2$s): All thumbnails was successfully regenerated in %3$s seconds.</b>', 'force-regenerate-thumbnails') . $regenerate_status, esc_html(get_the_title($image->ID)), $image->ID, timer_stop()) . $message;
|
481 |
die(json_encode(array('success' => $message)));
|
482 |
}
|
483 |
|
readme.txt
CHANGED
@@ -5,15 +5,13 @@ Tested up to: 3.4.1
|
|
5 |
Stable tag: trunk
|
6 |
Tags: force, regenerate thumbnails, thumbnail, thumbnails
|
7 |
|
8 |
-
|
9 |
|
10 |
== Description ==
|
11 |
|
12 |
-
* Based in Regenerate Thumbnails
|
13 |
|
14 |
-
Force Regenerate Thumbnails allows you to REALLY regenerate the thumbnails for your image attachments.
|
15 |
-
|
16 |
-
You can either regenerate the thumbnails for all image uploads, individual image uploads, or specific multiple image uploads.
|
17 |
|
18 |
See the [screenshots tab](http://wordpress.org/extend/plugins/force-regenerate-thumbnails/screenshots/) for more details.
|
19 |
|
@@ -31,6 +29,10 @@ See the [screenshots tab](http://wordpress.org/extend/plugins/force-regenerate-t
|
|
31 |
|
32 |
== ChangeLog ==
|
33 |
|
|
|
|
|
|
|
|
|
34 |
= 1.0 =
|
35 |
* First release.
|
36 |
|
5 |
Stable tag: trunk
|
6 |
Tags: force, regenerate thumbnails, thumbnail, thumbnails
|
7 |
|
8 |
+
Delete and REALLY force the regenerate thumbnail.
|
9 |
|
10 |
== Description ==
|
11 |
|
12 |
+
* Based in plugin: Regenerate Thumbnails - All credits and thanks to Viper007Bond
|
13 |
|
14 |
+
Force Regenerate Thumbnails allows you to delete all old images size and REALLY regenerate the thumbnails for your image attachments.
|
|
|
|
|
15 |
|
16 |
See the [screenshots tab](http://wordpress.org/extend/plugins/force-regenerate-thumbnails/screenshots/) for more details.
|
17 |
|
29 |
|
30 |
== ChangeLog ==
|
31 |
|
32 |
+
= 1.1 =
|
33 |
+
* Delete all custom image sizes when regenerate thumbnails
|
34 |
+
* Notifies you when thumbnails was deleted
|
35 |
+
|
36 |
= 1.0 =
|
37 |
* First release.
|
38 |
|