public static function thumbnail_rebuild($att_id, $thumbnails = null)
{
// Time a the begining
timer_start();
// Check Id
if ((int) $att_id <= 0) {
return array('time' => timer_stop(false, 4), 'error' => __('No id given in POST datas.', 'simple-image-sizes'));
}
// Get the path
$fullsizepath = get_attached_file($att_id);
// Regen the attachment
if (false !== $fullsizepath && file_exists($fullsizepath)) {
if (false == wp_update_attachment_metadata($att_id, self::wp_generate_attachment_metadata_custom($att_id, $fullsizepath, $thumbnails))) {
return array('src' => wp_get_attachment_thumb_url($att_id), 'time' => timer_stop(false, 4), 'message' => sprintf(__('This file already exists in this size and have not been regenerated :<br/><a target="_blank" href="%1$s" >%2$s</a>', 'simple-image-sizes'), get_edit_post_link($att_id), get_the_title($att_id)));
}
} else {
return array('src' => wp_get_attachment_thumb_url($att_id), 'time' => timer_stop(false, 4), 'error' => sprintf(__('This file does not exists and have not been regenerated :<br/><a target="_blank" href="%1$s" >%2$s</a>', 'simple-image-sizes'), get_edit_post_link($att_id), get_the_title($att_id)));
}
// Display the attachment url for feedback
return array('time' => timer_stop(false, 4), 'src' => wp_get_attachment_thumb_url($att_id), 'title' => get_the_title($att_id));
}