Last active
December 29, 2015 13:06
-
-
Save waelio/31976cadcac0a01745a4 to your computer and use it in GitHub Desktop.
Remove unreal images from wp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$imgs = get_posts("post_type=attachment&numberposts=-1"); | |
$x=0; | |
foreach($imgs as $img){ | |
$file = get_attached_file($img->ID); | |
$Image_size = getimagesize($file); | |
if(!is_array($Image_size)){ | |
wp_delete_post( $img->ID, false ); | |
echo $x .'- Deleting attachment #'.$img->ID; | |
}else{ | |
echo $x .'- OK! attachment #'.$img->ID; | |
} | |
echo '<br />'; | |
$x++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment