I've several wordpress sites and I'm using bulk media upload (my own script). But sometimes, for server issues or image issues, upload failing. I don't want to reupload these image but I don't want to they exist in my media gallery too. I've tried wordpress broken link checker plugin but it's working embedded medias in post but not in the embedded galleries. So, is there any way to check media files really exist and delete broken ones? Thanks.

有帮助吗?

解决方案

You can use WP Image Editor to check, try:

$image = wp_get_image_editor( 'my_image.jpg' );
if (is_wp_error($image)){
  //do some action, like add image path and name to array of broken images
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top