1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
$imagens = $wpdb->get_results(' SELECT ID FROM wp_posts WHERE post_type = "attachment" AND ( post_mime_type = "image/gif" OR post_mime_type = "image/jpeg" OR post_mime_type = "image/png" ) '); $indice = 1; foreach($imagens as $imagem){ $file = get_attached_file($imagem->ID); $fileAr = explode('.',$file); $fileArEx = end($fileAr); array_pop($fileAr); $fileSized = implode('.',$fileAr).'-150x150.'.$fileArEx; if(file_exists($file) && !file_exists($fileSized)){ echo $indice.' - '.$file; echo '<br>'; $metadata = wp_generate_attachment_metadata( $imagem->ID, $file ); wp_update_attachment_metadata( $imagem->ID, $metadata ); $indice++; } } |