WooCommerce Code Reference

Search results

WC_Regenerate_Images

Regenerate Images Class

Table of Contents

$background_process Background process to regenerate all images WC_Regenerate_Images_Request
$regenerate_size Stores size being generated on the fly. string
init() Init function mixed
filter_image_get_intermediate_size() If an intermediate size meta differs from the actual image size (settings were changed?) return false so the wrong size is not used. array
add_uncropped_metadata() We need to track if uncropped was on or off when generating the images. array
image_size_matches_settings() See if an image's dimensions match actual settings. bool
regenerating_notice() Show notice when job is running in background. mixed
dismiss_regenerating_notice() Dismiss notice and cancel jobs. mixed
maybe_regenerate_images() Regenerate images if the settings have changed since last re-generation. void
maybe_resize_image() Check if we should maybe generate a new image size if not already there. array
get_full_size_image_dimensions() Get full size image dimensions. array
is_regeneratable() Ensure we are dealing with the correct image attachment bool
adjust_intermediate_image_sizes() Only regenerate images for the requested size. array
get_image() Generate the thumbnail filename and dimensions for a given file. array|false
resize_and_return_image() Regenerate the image according to the required size string
unfiltered_image_downsize() Image downsize, without this classes filtering on the results. string
queue_image_regeneration() Get list of images and queue them for regeneration void

Properties

Methods

filter_image_get_intermediate_size()

If an intermediate size meta differs from the actual image size (settings were changed?) return false so the wrong size is not used.

public static filter_image_get_intermediate_size( $data : array , $attachment_id : int , $size : string ) : array
Parameters
$data : array

Size data.

$attachment_id : int

Attachment ID.

$size : string

Size name.

Return values
array

add_uncropped_metadata()

We need to track if uncropped was on or off when generating the images.

public static add_uncropped_metadata( $meta_data : array ) : array
Parameters
$meta_data : array

Array of meta data.

Return values
array

image_size_matches_settings()

See if an image's dimensions match actual settings.

protected static image_size_matches_settings( $image : array , $size : string ) : bool
Parameters
$image : array

Image dimensions array.

$size : string

Named size.

Return values
bool

True if they match. False if they do not (may trigger regen).

regenerating_notice()

Show notice when job is running in background.

public static regenerating_notice( ) : mixed
Return values
mixed

dismiss_regenerating_notice()

Dismiss notice and cancel jobs.

public static dismiss_regenerating_notice( ) : mixed
Return values
mixed

maybe_regenerate_images()

Regenerate images if the settings have changed since last re-generation.

public static maybe_regenerate_images( ) : void

maybe_resize_image()

Check if we should maybe generate a new image size if not already there.

public static maybe_resize_image( $image : array , $attachment_id : int , $size : string|array , $icon : bool ) : array
Parameters
$image : array

Properties of the image.

$attachment_id : int

Attachment ID.

$size : string|array

Image size.

$icon : bool

If icon or not.

Return values
array

get_full_size_image_dimensions()

Get full size image dimensions.

private static get_full_size_image_dimensions( $attachment_id : int ) : array
Parameters
$attachment_id : int

Attachment ID of image.

Return values
array

Width and height. Empty array if the dimensions cannot be found.

is_regeneratable()

Ensure we are dealing with the correct image attachment

public static is_regeneratable( $attachment : int|WP_Post ) : bool
Parameters
$attachment : int|WP_Post

Attachment object or ID.

Return values
bool

adjust_intermediate_image_sizes()

Only regenerate images for the requested size.

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

Array of image sizes.

Return values
array

get_image()

Generate the thumbnail filename and dimensions for a given file.

private static get_image( $fullsizepath : string , $thumbnail_width : int , $thumbnail_height : int , $crop : bool ) : array|false
Parameters
$fullsizepath : string

Path to full size image.

$thumbnail_width : int

The width of the thumbnail.

$thumbnail_height : int

The height of the thumbnail.

$crop : bool

Whether to crop or not.

Return values
array|false

An array of the filename, thumbnail width, and thumbnail height, or false on failure to resize such as the thumbnail being larger than the fullsize image.

resize_and_return_image()

Regenerate the image according to the required size

private static resize_and_return_image( $attachment_id : int , $image : array , $size : string , $icon : bool ) : string
Parameters
$attachment_id : int

Attachment ID.

$image : array

Original Image.

$size : string

Size to return for new URL.

$icon : bool

If icon or not.

Return values
string

unfiltered_image_downsize()

Image downsize, without this classes filtering on the results.

private static unfiltered_image_downsize( $attachment_id : int , $size : string ) : string
Parameters
$attachment_id : int

Attachment ID.

$size : string

Size to downsize to.

Return values
string

New image URL.

queue_image_regeneration()

Get list of images and queue them for regeneration

public static queue_image_regeneration( ) : void
Back to the top