| @@ -134,9 +134,11 @@ | ||
| 134 | 134 | * @param string $context The context. |
| 135 | 135 | * @return bool|WP_Error True if successfully launched. A \WP_Error instance on failure. |
| 136 | 136 | */ |
| 137 | 137 | protected function optimize_media( $media_id, $context ) { |
| 138 | - return imagify_get_optimization_process( $media_id, $context )->optimize(); | |
| 138 | + // A manual click is an explicit, single-image user action: flag it as priority so it | |
| 139 | + // jumps ahead of any bulk optimization queue. | |
| 140 | + return imagify_get_optimization_process( $media_id, $context )->optimize( null, [ 'priority' => true ] ); | |
| 139 | 141 | } |
| 140 | 142 | |
| 141 | 143 | /** |
| 142 | 144 | * Re-optimize a media to a different optimization level. |
| @@ -148,9 +150,11 @@ | ||
| 148 | 150 | * @param int $level The optimization level. |
| 149 | 151 | * @return bool|WP_Error True if successfully launched. A \WP_Error instance on failure. |
| 150 | 152 | */ |
| 151 | 153 | protected function reoptimize_media( $media_id, $context, $level ) { |
| 152 | - return imagify_get_optimization_process( $media_id, $context )->reoptimize( $level ); | |
| 154 | + // A manual click is an explicit, single-image user action: flag it as priority so it | |
| 155 | + // jumps ahead of any bulk optimization queue. | |
| 156 | + return imagify_get_optimization_process( $media_id, $context )->reoptimize( $level, [ 'priority' => true ] ); | |
| 153 | 157 | } |
| 154 | 158 | |
| 155 | 159 | /** |
| 156 | 160 | * Optimize all files from a media, whatever this media’s previous optimization status (will be restored if needed). |