Changeset 408875
- Timestamp:
- 07/12/2011 07:06:17 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ajax-thumbnail-rebuild/trunk/ajax-thumbnail-rebuild.php
r407551 r408875 57 57 } 58 58 59 var onlypostthumbs = jQuery("#onlypostthumbs").attr('checked') ? 1 : 0; 60 59 61 jQuery.ajax({ 60 62 url: "<?php bloginfo('wpurl'); ?>/wp-admin/admin-ajax.php", 61 63 type: "POST", 62 data: "action=ajax_thumbnail_rebuild&do=getlist ",64 data: "action=ajax_thumbnail_rebuild&do=getlist&onlypostthumbs="+onlypostthumbs, 63 65 success: function(result) { 64 66 var list = eval(result); … … 130 132 <?php endforeach;?> 131 133 </p> 134 <p> 135 <input type="checkbox" id="onlypostthumbs" name="onlypostthumbs" /> 136 <label>Only rebuild post thumbnails</label> 137 </p> 138 132 139 <input type="button" onClick="javascript:regenerate();" class="button" 133 140 name="ajax_thumbnail_rebuild" id="ajax_thumbnail_rebuild" … … 150 157 151 158 function ajax_thumbnail_rebuild_ajax() { 159 global $wpdb; 160 152 161 $action = $_POST["do"]; 153 162 $thumbnails = isset( $_POST['thumbnails'] )? $_POST['thumbnails'] : NULL; 163 $onlypostthumbs = isset( $_POST['onlypostthumbs'] ) ? $_POST['onlypostthumbs'] : 0; 154 164 155 165 if ($action == "getlist") { 156 $attachments =& get_children( array( 157 'post_type' => 'attachment', 158 'post_mime_type' => 'image', 159 'numberposts' => -1, 160 'post_status' => null, 161 'post_parent' => null, // any parent 162 'output' => 'object', 163 ) ); 166 167 if ($onlypostthumbs) { 168 /* Get all featured images */ 169 $featured_images = $wpdb->get_results( "SELECT meta_value FROM {$wpdb->postmeta} 170 WHERE meta_key = '_thumbnail_id'" ); 171 172 $thumbs = array(); 173 foreach($featured_images as $image) { 174 array_push($thumbs, $image->meta_value); 175 } 176 $attachments =& get_children( array( 177 'post_type' => 'attachment', 178 'post_mime_type' => 'image', 179 'numberposts' => -1, 180 'post_status' => null, 181 'post_in' => $thumbs, 182 'output' => 'object', 183 ) ); 184 185 } else { 186 $attachments =& get_children( array( 187 'post_type' => 'attachment', 188 'post_mime_type' => 'image', 189 'numberposts' => -1, 190 'post_status' => null, 191 'post_parent' => null, // any parent 192 'output' => 'object', 193 ) ); 194 } 164 195 165 196 foreach ( $attachments as $attachment ) {
Note: See TracChangeset
for help on using the changeset viewer.