'attachment', 'post_mime_type' => 'image', 'post_status' => 'inherit', 'posts_per_page' => -1, ); $images_query = new WP_Query($query_args); $images = array(); foreach ($images_query->posts as $img) { $alt = get_post_meta($img->ID, '_wp_attachment_image_alt', true); if(strlen($alt) === 0) { $img_object = array( 'id' => $img->ID, 'name' => $img->post_title, 'url' => wp_get_attachment_thumb_url($img->ID) ); $images[] = $img_object; } } ?>