thumbnail_rebuild() public static method

Rebuild the given attribute with the given thumbnails
Author: Nicolas Juen
public static thumbnail_rebuild ( $att_id, $thumbnails = null ) : array
$att_id
$thumbnails
return array
コード例 #1
0
ファイル: post.php プロジェクト: yarylo/cerkva.pp.ua
 /**
  * Rebuild the image
  *
  * @access public
  * @return void
  * @author Nicolas Juen
  */
 public static function a_thumbnail_rebuild()
 {
     // Get the nonce
     $nonce = isset($_POST['nonce']) ? $_POST['nonce'] : '';
     // Get the thumbnails
     $thumbnails = isset($_POST['thumbnails']) ? $_POST['thumbnails'] : null;
     // Check the nonce
     if (!wp_verify_nonce($nonce, 'regen')) {
         SIS_Admin_Main::display_json(array('error' => __('Trying to cheat ?', 'simple-image-sizes')));
     }
     // Get the id
     $id = isset($_POST['id']) ? $_POST['id'] : 0;
     SIS_Admin_Main::display_json(SIS_Admin_Main::thumbnail_rebuild($id, $thumbnails));
 }
コード例 #2
0
ファイル: media.php プロジェクト: Allan019/grupometa
 /**
  * Regenerate the thumbnails ajax action
  *
  * @return array
  * @param void
  * @author Nicolas Juen
  */
 public static function a_thumbnails_rebuild()
 {
     // Get the nonce
     $nonce = isset($_POST['nonce']) ? $_POST['nonce'] : '';
     $offset = isset($_POST['offset']) ? absint($_POST['offset']) : 0;
     $post_types = isset($_POST['post_types']) ? $_POST['post_types'] : 'any';
     $thumbnails = isset($_POST['thumbnails']) ? $_POST['thumbnails'] : NULL;
     // Check the nonce
     if (!wp_verify_nonce($nonce, 'regen')) {
         SIS_Admin_Main::displayJson(array('error' => __('Trying to cheat ?', 'simple-image-sizes')));
     }
     if ($post_types !== 'any') {
         foreach ($_POST['post_types'] as $key => $type) {
             if (!post_type_exists($type)) {
                 unset($_POST['post_types'][$key]);
             }
         }
         if (empty($_POST['post_types'])) {
             SIS_Admin_Main::displayJson();
         }
         // Get image medias
         $whichmimetype = wp_post_mime_type_where('image', $wpdb->posts);
         // Get all parent from post type
         $attachment = $wpdb->get_var($wpdb->prepare("SELECT ID\r\n\t\t\t\tFROM {$wpdb->posts} \r\n\t\t\t\tWHERE 1 = 1\r\n\t\t\t\tAND post_type = 'attachment'\r\n\t\t\t\t{$whichmimetype}\r\n\t\t\t\tAND post_parent IN (\r\n\t\t\t\t\tSELECT DISTINCT ID \r\n\t\t\t\t\tFROM {$wpdb->posts} \r\n\t\t\t\t\tWHERE post_type IN ('" . implode("', '", $_POST['post_types']) . "')\r\n\t\t\t\t)\r\n\t\t\t\tLIMIT %d,1 \r\n\t\t\t", $offset));
     } else {
         $attachment = get_posts(array('post_type' => 'attachment', 'post_mime_type' => 'image', 'numberposts' => 1, 'post_status' => 'any', 'output' => 'object', 'offset' => $offset));
         $attachment = !empty($attachment) ? $attachment[0]->ID : 0;
     }
     if (empty($attachment)) {
         return array('message' => __('Regeneration ended', 'simple-image-sizes'));
     }
     SIS_Admin_Main::displayJson(SIS_Admin_Main::thumbnail_rebuild($attachment, $thumbnails));
 }
コード例 #3
-1
ファイル: post.php プロジェクト: EcvetStep/ecvet-step.eu
 /**
  * Rebuild the image
  * 
  * @access public
  * @return void
  * @author Nicolas Juen
  */
 public static function a_thumbnail_rebuild()
 {
     global $wpdb;
     // Get the nonce
     $nonce = isset($_POST['nonce']) ? $_POST['nonce'] : '';
     // Time a the begining
     timer_start();
     // Get the thumbnails
     $thumbnails = isset($_POST['thumbnails']) ? $_POST['thumbnails'] : NULL;
     // Check the nonce
     if (!wp_verify_nonce($nonce, 'regen')) {
         SIS_Admin_Main::displayJson(array('error' => _e('Trying to cheat ?', 'simple-image-sizes')));
     }
     // Get the id
     $id = isset($_POST["id"]) ? $_POST["id"] : 0;
     SIS_Admin_Main::displayJson(SIS_Admin_Main::thumbnail_rebuild($id, $thumbnails));
 }