Images are displaying as blank images
You should generate the attachment metadata such as width and height — and file path, and also thumbnails, after you created the attachment: Using wp_generate_attachment_metadata(): $attach_id = wp_insert_attachment( $attachment, $filename ); if ( $attach_id ) { require_once ABSPATH . ‘wp-admin/includes/image.php’; $metadata = wp_generate_attachment_metadata( $attach_id, $filename ); wp_update_attachment_metadata( $attach_id, $metadata ); } Using wp_maybe_generate_attachment_metadata(): $attach_id = … Read more