WC_Regenerate_Images::queue_image_regeneration()
Get list of images and queue them for regeneration
Description Description
Return Return
(void)
Source Source
File: includes/class-wc-regenerate-images.php
public static function queue_image_regeneration() {
global $wpdb;
// First lets cancel existing running queue to avoid running it more than once.
self::$background_process->kill_process();
// Now lets find all product image attachments IDs and pop them onto the queue.
$images = $wpdb->get_results( // @codingStandardsIgnoreLine
"SELECT ID
FROM $wpdb->posts
WHERE post_type = 'attachment'
AND post_mime_type LIKE 'image/%'
ORDER BY ID DESC"
);
foreach ( $images as $image ) {
self::$background_process->push_to_queue(
array(
'attachment_id' => $image->ID,
)
);
}
// Lets dispatch the queue to start processing.
self::$background_process->save()->dispatch();
}