WC_Regenerate_Images_Request
extends WC_Background_Process
in package
Class that extends WC_Background_Process to process image regeneration in the background.
Table of Contents
- $attachment_id : int
- Stores the attachment ID being processed.
- __construct() : mixed
- Initiate new background process.
- adjust_intermediate_image_sizes() : array<string|int, mixed>
- Returns the sizes we want to regenerate.
- delete_all_batches() : WC_Background_Process
- Delete all batches.
- filter_image_sizes_to_only_missing_thumbnails() : array<string|int, mixed>
- Filters the list of thumbnail sizes to only include those which have missing files.
- is_running() : bool
- Is job running?
- kill_process() : mixed
- Kill process.
- schedule_cron_healthcheck() : array<string|int, mixed>
- Schedule cron healthcheck.
- batch_limit_exceeded() : bool
- Limit each task ran per batch to 1 for image regen.
- complete() : void
- This runs once the job has completed all items on the queue.
- get_batch() : stdClass
- Get batch.
- get_memory_limit() : int
- Get memory limit.
- handle() : mixed
- Handle.
- is_queue_empty() : bool
- Is queue empty.
- is_regeneratable() : bool
- Determines whether an attachment can have its thumbnails regenerated.
- task() : bool
- Code to execute for each item in the queue
Properties
$attachment_id
Stores the attachment ID being processed.
protected
int
$attachment_id
= 0
Methods
__construct()
Initiate new background process.
public
__construct() : mixed
Return values
mixed —adjust_intermediate_image_sizes()
Returns the sizes we want to regenerate.
public
adjust_intermediate_image_sizes(array<string|int, mixed> $sizes) : array<string|int, mixed>
Parameters
- $sizes : array<string|int, mixed>
-
Sizes to generate.
Return values
array<string|int, mixed> —delete_all_batches()
Delete all batches.
public
delete_all_batches() : WC_Background_Process
Return values
WC_Background_Process —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(array<string|int, mixed> $sizes, array<string|int, mixed> $metadata[, int $attachment_id = null ]) : array<string|int, mixed>
Parameters
- $sizes : array<string|int, mixed>
-
An associative array of registered thumbnail image sizes.
- $metadata : array<string|int, mixed>
-
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<string|int, mixed> — An associative array of image sizes.is_running()
Is job running?
public
is_running() : bool
Return values
bool —kill_process()
Kill process.
public
kill_process() : mixed
Stop processing queue items, clear cronjob and delete all batches.
Return values
mixed —schedule_cron_healthcheck()
Schedule cron healthcheck.
public
schedule_cron_healthcheck(array<string|int, mixed> $schedules) : array<string|int, mixed>
Parameters
- $schedules : array<string|int, mixed>
-
Schedules.
Return values
array<string|int, mixed> —batch_limit_exceeded()
Limit each task ran per batch to 1 for image regen.
protected
batch_limit_exceeded() : bool
Return values
bool —complete()
This runs once the job has completed all items on the queue.
protected
complete() : void
Return values
void —get_batch()
Get batch.
protected
get_batch() : stdClass
Return values
stdClass — Return the first batch from the queue.get_memory_limit()
Get memory limit.
protected
get_memory_limit() : int
Return values
int —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 —is_queue_empty()
Is queue empty.
protected
is_queue_empty() : bool
Return values
bool —is_regeneratable()
Determines whether an attachment can have its thumbnails regenerated.
protected
is_regeneratable(WP_Post $attachment) : 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(mixed $item) : bool
Parameters
- $item : mixed
-
Queue item to iterate over.