WooCommerce Code Reference

Search results

WC_Regenerate_Images_Request extends WC_Background_Process

Class that extends WC_Background_Process to process image regeneration in the background.

Table of Contents

$attachment_id Stores the attachment ID being processed. int
__construct() Initiate new background process. mixed
is_running() Is job running? bool
batch_limit_exceeded() Limit each task ran per batch to 1 for image regen. bool
is_regeneratable() Determines whether an attachment can have its thumbnails regenerated. bool
task() Code to execute for each item in the queue bool
filter_image_sizes_to_only_missing_thumbnails() Filters the list of thumbnail sizes to only include those which have missing files. array
adjust_intermediate_image_sizes() Returns the sizes we want to regenerate. array
complete() This runs once the job has completed all items on the queue. void
is_queue_empty() Is queue empty. bool
get_batch() Get batch. stdClass
batch_limit_exceeded() See if the batch limit has been exceeded. bool
handle() Handle. mixed
get_memory_limit() Get memory limit. int
schedule_cron_healthcheck() Schedule cron healthcheck. array
delete_all_batches() Delete all batches. WC_Background_Process
kill_process() Kill process. mixed

Properties

Methods

is_regeneratable()

Determines whether an attachment can have its thumbnails regenerated.

protected is_regeneratable( $attachment : WP_Post ) : bool

Adapted from Regenerate Thumbnails by Alex Mills.

Parameters
$attachment : WP_Post

An attachment's post object.

Return values
bool

Whether the given attachment can have its thumbnails regenerated.

task()

Code to execute for each item in the queue

protected task( $item : mixed ) : bool
Parameters
$item : mixed

Queue item to iterate over.

Return values
bool

filter_image_sizes_to_only_missing_thumbnails()

Filters the list of thumbnail sizes to only include those which have missing files.

public filter_image_sizes_to_only_missing_thumbnails( $sizes : array , $metadata : array [, $attachment_id : int = null ] ) : array
Parameters
$sizes : array

An associative array of registered thumbnail image sizes.

$metadata : array

An associative array of fullsize image metadata: width, height, file.

$attachment_id : int = null

Attachment ID. Only passed from WP 5.0+.

Return values
array

An associative array of image sizes.

adjust_intermediate_image_sizes()

Returns the sizes we want to regenerate.

public adjust_intermediate_image_sizes( $sizes : array ) : array
Parameters
$sizes : array

Sizes to generate.

Return values
array

get_batch()

Get batch.

protected get_batch( ) : stdClass
Return values
stdClass

Return the first batch from the queue.

batch_limit_exceeded()

See if the batch limit has been exceeded.

protected batch_limit_exceeded( ) : bool
Return values
bool

handle()

Handle.

protected handle( ) : mixed

Pass each queue item to the task handler, while remaining within server memory and time limit constraints.

Return values
mixed

schedule_cron_healthcheck()

Schedule cron healthcheck.

public schedule_cron_healthcheck( $schedules : array ) : array
Parameters
$schedules : array

Schedules.

Return values
array

kill_process()

Kill process.

public kill_process( ) : mixed

Stop processing queue items, clear cronjob and delete all batches.

Return values
mixed
Back to the top