public function pim_pim_images($post_id, $title_image = true)
 {
     $images = PIM_Gallery::get_list($post_id, true);
     if (!empty($images) && $images) {
         if (count($images) > 1) {
             reset($images);
             $key = key($images);
             $retArr = array();
             if ($title_image) {
                 $retArr['title_image'] = $images[$key];
                 unset($images[$key]);
             }
             foreach ($images as $image) {
                 $retArr['thumbs'][] = $image;
             }
             if ($title_image) {
                 return $retArr;
             }
             return $retArr['thumbs'];
         }
     }
     return $images;
 }
 function meta_box_save($post_id)
 {
     if (in_array(get_post_type($post_id), $this->post_types)) {
         if (!isset($_POST['_inline_edit'])) {
             $attachments = PIM_Gallery::get_list($post_id, true);
             if (isset($_POST['pim-save-form-nonce']) && wp_verify_nonce($_POST['pim-save-form-nonce'], 'pim-form-save')) {
                 // see if image data was submitted:
                 // sanitize the data and save it in the term_images array
                 if (!empty($_POST[$this->upload_id])) {
                     $images = $_POST[$this->upload_id];
                     if (!empty($_POST['uploaded_img'])) {
                         $images .= implode(',', $_POST['uploaded_img']);
                     }
                     delete_post_meta($post_id, $this->upload_id);
                     add_post_meta($post_id, $this->upload_id, json_encode($images), true);
                 }
             }
             if (isset($_POST['images_order']) && !empty($_POST['images_order'])) {
                 delete_post_meta($post_id, $this->upload_id);
                 update_post_meta($post_id, $this->upload_id, json_encode(implode(',', $_POST['images_order'])));
             }
             if (!isset($_POST['images_order']) && !isset($_POST['uploaded_img']) && empty($_POST[$this->upload_id])) {
                 delete_post_meta($post_id, $this->upload_id);
             }
         }
     }
 }