Version Description
- NEW: Rebuild thumbnails of single images on the media attachment page.
Download this release
Release Info
Developer | junkcoder |
Plugin | AJAX Thumbnail Rebuild |
Version | 1.10 |
Comparing to | |
See all releases |
Code changes from version 1.09 to 1.10
- ajax-thumbnail-rebuild.php +64 -6
- readme.txt +5 -1
ajax-thumbnail-rebuild.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin URI: http://breiti.cc/wordpress/ajax-thumbnail-rebuild
|
4 |
Author: junkcoder
|
5 |
Author URI: http://breiti.cc
|
6 |
-
Version: 1.
|
7 |
Description: Rebuild all thumbnails
|
8 |
Max WP Version: 3.6.1
|
9 |
Text Domain: ajax-thumbnail-rebuild
|
@@ -27,6 +27,7 @@ class AjaxThumbnailRebuild {
|
|
27 |
|
28 |
function AjaxThumbnailRebuild() {
|
29 |
add_action( 'admin_menu', array(&$this, 'addAdminMenu') );
|
|
|
30 |
}
|
31 |
|
32 |
function addAdminMenu() {
|
@@ -34,6 +35,61 @@ class AjaxThumbnailRebuild {
|
|
34 |
), 'manage_options', 'ajax-thumbnail-rebuild', array(&$this, 'ManagementPage') );
|
35 |
}
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
function ManagementPage() {
|
38 |
?>
|
39 |
<div id="message" class="updated fade" style="display:none"></div>
|
@@ -86,10 +142,11 @@ class AjaxThumbnailRebuild {
|
|
86 |
type: "POST",
|
87 |
data: "action=ajax_thumbnail_rebuild&do=regen&id=" + list[curr].id + thumbnails,
|
88 |
success: function(result) {
|
89 |
-
jQuery("#thumb").show();
|
90 |
-
jQuery("#thumb-img").attr("src",result);
|
91 |
-
|
92 |
curr = curr + 1;
|
|
|
|
|
|
|
|
|
93 |
regenItem();
|
94 |
}
|
95 |
});
|
@@ -178,7 +235,7 @@ function ajax_thumbnail_rebuild_ajax() {
|
|
178 |
$res[] = array('id' => $image->meta_value, 'title' => $image->title);
|
179 |
}
|
180 |
} else {
|
181 |
-
$attachments
|
182 |
'post_type' => 'attachment',
|
183 |
'post_mime_type' => 'image',
|
184 |
'numberposts' => -1,
|
@@ -200,9 +257,10 @@ function ajax_thumbnail_rebuild_ajax() {
|
|
200 |
if ( FALSE !== $fullsizepath && @file_exists($fullsizepath) ) {
|
201 |
set_time_limit( 30 );
|
202 |
wp_update_attachment_metadata( $id, wp_generate_attachment_metadata_custom( $id, $fullsizepath, $thumbnails ) );
|
|
|
203 |
}
|
204 |
|
205 |
-
die(
|
206 |
}
|
207 |
}
|
208 |
add_action('wp_ajax_ajax_thumbnail_rebuild', 'ajax_thumbnail_rebuild_ajax');
|
3 |
Plugin URI: http://breiti.cc/wordpress/ajax-thumbnail-rebuild
|
4 |
Author: junkcoder
|
5 |
Author URI: http://breiti.cc
|
6 |
+
Version: 1.10
|
7 |
Description: Rebuild all thumbnails
|
8 |
Max WP Version: 3.6.1
|
9 |
Text Domain: ajax-thumbnail-rebuild
|
27 |
|
28 |
function AjaxThumbnailRebuild() {
|
29 |
add_action( 'admin_menu', array(&$this, 'addAdminMenu') );
|
30 |
+
add_filter( 'attachment_fields_to_edit', array(&$this, 'addRebuildSingle') );
|
31 |
}
|
32 |
|
33 |
function addAdminMenu() {
|
35 |
), 'manage_options', 'ajax-thumbnail-rebuild', array(&$this, 'ManagementPage') );
|
36 |
}
|
37 |
|
38 |
+
/**
|
39 |
+
* Add rebuild thumbnails button to the media page
|
40 |
+
*
|
41 |
+
* @param array $fields
|
42 |
+
* @param object $post
|
43 |
+
* @return array
|
44 |
+
*/
|
45 |
+
function addRebuildSingle($fields, $post) {
|
46 |
+
global $post;
|
47 |
+
$thumbnails = array();
|
48 |
+
foreach ( ajax_thumbnail_rebuild_get_sizes() as $s )
|
49 |
+
$thumbnails[] = 'thumbnails[]='.$s['name'];
|
50 |
+
$thumbnails = '&'.implode('&', $thumbnails);
|
51 |
+
ob_start();
|
52 |
+
?>
|
53 |
+
<script>
|
54 |
+
function setMessage(msg) {
|
55 |
+
jQuery("#atr-message").html(msg);
|
56 |
+
jQuery("#atr-message").show();
|
57 |
+
}
|
58 |
+
|
59 |
+
function regenerate() {
|
60 |
+
jQuery("#ajax_thumbnail_rebuild").prop("disabled", true);
|
61 |
+
setMessage("<?php _e('Reading attachments...', 'ajax-thumbnail-rebuild') ?>");
|
62 |
+
thumbnails = '<?php echo $thumbnails ?>';
|
63 |
+
jQuery.ajax({
|
64 |
+
url: "<?php echo admin_url('admin-ajax.php'); ?>",
|
65 |
+
type: "POST",
|
66 |
+
data: "action=ajax_thumbnail_rebuild&do=regen&id=<?php echo $post->ID ?>" + thumbnails,
|
67 |
+
success: function(result) {
|
68 |
+
if (result != '-1') {
|
69 |
+
setMessage("<?php _e('Done.', 'ajax-thumbnail-rebuild') ?>");
|
70 |
+
}
|
71 |
+
},
|
72 |
+
error: function(request, status, error) {
|
73 |
+
setMessage("<?php _e('Error', 'ajax-thumbnail-rebuild') ?>" + request.status);
|
74 |
+
},
|
75 |
+
complete: function() {
|
76 |
+
jQuery("#ajax_thumbnail_rebuild").prop("disabled", false);
|
77 |
+
}
|
78 |
+
});
|
79 |
+
}
|
80 |
+
</script>
|
81 |
+
<input type='button' onclick='javascript:regenerate();' class='button' name='ajax_thumbnail_rebuild' id='ajax_thumbnail_rebuild' value='Rebuild Thumbnails'>
|
82 |
+
<span id="atr-message" class="updated fade" style="clear:both;display:none;line-height:28px;padding-left:10px;"></span>
|
83 |
+
<?php
|
84 |
+
$html = ob_get_clean();
|
85 |
+
$fields["ajax-thumbnail-rebuild"] = array(
|
86 |
+
"label" => __('Ajax Thumbnail Rebuild', 'ajax-thumbnail-rebuild'),
|
87 |
+
"input" => "html",
|
88 |
+
"html" => $html
|
89 |
+
);
|
90 |
+
return $fields;
|
91 |
+
}
|
92 |
+
|
93 |
function ManagementPage() {
|
94 |
?>
|
95 |
<div id="message" class="updated fade" style="display:none"></div>
|
142 |
type: "POST",
|
143 |
data: "action=ajax_thumbnail_rebuild&do=regen&id=" + list[curr].id + thumbnails,
|
144 |
success: function(result) {
|
|
|
|
|
|
|
145 |
curr = curr + 1;
|
146 |
+
if (result != '-1') {
|
147 |
+
jQuery("#thumb").show();
|
148 |
+
jQuery("#thumb-img").attr("src",result);
|
149 |
+
}
|
150 |
regenItem();
|
151 |
}
|
152 |
});
|
235 |
$res[] = array('id' => $image->meta_value, 'title' => $image->title);
|
236 |
}
|
237 |
} else {
|
238 |
+
$attachments = get_children( array(
|
239 |
'post_type' => 'attachment',
|
240 |
'post_mime_type' => 'image',
|
241 |
'numberposts' => -1,
|
257 |
if ( FALSE !== $fullsizepath && @file_exists($fullsizepath) ) {
|
258 |
set_time_limit( 30 );
|
259 |
wp_update_attachment_metadata( $id, wp_generate_attachment_metadata_custom( $id, $fullsizepath, $thumbnails ) );
|
260 |
+
die( wp_get_attachment_thumb_url( $id ));
|
261 |
}
|
262 |
|
263 |
+
die('-1');
|
264 |
}
|
265 |
}
|
266 |
add_action('wp_ajax_ajax_thumbnail_rebuild', 'ajax_thumbnail_rebuild_ajax');
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://breiti.cc/wordpress/ajax-thumbnail-rebuild/#donate
|
|
4 |
Tags: ajax, thumbnail, rebuild, regenerate, admin, image, photo
|
5 |
Requires at least: 2.8
|
6 |
Tested up to: 3.6.1
|
7 |
-
Stable tag: 1.
|
8 |
|
9 |
AJAX Thumbnail Rebuild allows you to rebuild all thumbnails at once without script timeouts on your server.
|
10 |
|
@@ -24,6 +24,10 @@ Upload the plugin to your blog, activate it, done. You can then rebuild all thum
|
|
24 |
|
25 |
== Changelog ==
|
26 |
|
|
|
|
|
|
|
|
|
27 |
= 1.09 =
|
28 |
|
29 |
* NEW: Checkboxes can be activated by clicking on text.
|
4 |
Tags: ajax, thumbnail, rebuild, regenerate, admin, image, photo
|
5 |
Requires at least: 2.8
|
6 |
Tested up to: 3.6.1
|
7 |
+
Stable tag: 1.10
|
8 |
|
9 |
AJAX Thumbnail Rebuild allows you to rebuild all thumbnails at once without script timeouts on your server.
|
10 |
|
24 |
|
25 |
== Changelog ==
|
26 |
|
27 |
+
= 1.10 =
|
28 |
+
|
29 |
+
* NEW: Rebuild thumbnails of single images on the media attachment page.
|
30 |
+
|
31 |
= 1.09 =
|
32 |
|
33 |
* NEW: Checkboxes can be activated by clicking on text.
|