diff --git a/classes/Bulk/Bulk.php b/classes/Bulk/Bulk.php index 94120175..2486b714 100644 --- a/classes/Bulk/Bulk.php +++ b/classes/Bulk/Bulk.php @@ -173,31 +173,17 @@ public function run_optimize( string $context, int $optimization_level ) { 'message' => 'over-quota', ]; } - $formats = imagify_nextgen_images_formats(); - $media_ids = [ - 'ids' => [], - 'errors' => [ - 'no_file_path' => [], - 'no_backup' => [], - ], - ]; - foreach ( $formats as $format ) { - $result = $this->get_bulk_instance( $context )->get_optimized_media_ids_without_format( $format ); - $media_ids['ids'] = array_merge( $media_ids['ids'], $result['ids'] ); - } - $get_unoptimized_media_ids = $this->get_bulk_instance( $context )->get_unoptimized_media_ids( $optimization_level ); - $media_ids['ids'] = array_merge( $media_ids['ids'], $get_unoptimized_media_ids ); + $media_ids = $this->get_bulk_instance( $context )->get_unoptimized_media_ids( $optimization_level ); - if ( empty( $media_ids['ids'] ) ) { + if ( empty( $media_ids ) ) { return [ 'success' => false, 'message' => 'no-images', ]; } - $media_ids['ids'] = array_unique( $media_ids['ids'] ); - foreach ( $media_ids['ids'] as $media_id ) { + foreach ( $media_ids as $media_id ) { try { as_enqueue_async_action( 'imagify_optimize_media',