Skip to content

Commit

Permalink
Fix number of media in the bulk optimization (#842)
Browse files Browse the repository at this point in the history
  • Loading branch information
remyperona authored Mar 12, 2024
1 parent 107f713 commit 3989cab
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions classes/Bulk/Bulk.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 3989cab

Please sign in to comment.