class-img-converter.php

Img_Converter Class

Source includes/Images/class-img-converter.php17 min readPart of Performance Optimisation

includes/Images/class-img-converter.php

Img_Converter Class

Namespace: PerformanceOptimise\\Inc · Lines: 4077

Class Img_Converter

Img_Converter Class

Source: includes/Images/class-img-converter.php, line 27

class Img_Converter

Tags: @since 1.0.0

Constants

ConstantVisibilityValueLine
SALT_KEYprivate\'wppo_img_info_salt\'69

Properties

PropertyVisibilityTypeDefaultLine
$deferred_img_infoprivate staticarray|nullnull35
$img_info_shutdown_registeredprivate staticboolfalse43
$img_info_persistedprivate staticboolfalse51
$client_side_processing_stateprivate staticarray<int,null61
$optionsprivatearray—77
$available_formatprivatearrayarray( \'webp\', \'avif\', \'both\', )85
$formatprivatestring—97
$exclude_imgsprivatearrayarray()105

public __construct()

public function __construct($options)

Img_Converter constructor.

ParameterTypeDefaultDescription
$optionsarray—Options for configuring image optimization.

Tags: @since 1.0.0

Source: includes/Images/class-img-converter.php, line 113

publicstatic core_handles_next_gen()

public static function core_handles_next_gen(): bool

Check if WordPress core (6.7+) natively handles next-gen format generation (WebP/AVIF).

Return: bool — True if core handles next-gen formats natively.

Tags: @since 2.0.0

Source: includes/Images/class-img-converter.php, line 139

publicstatic core_handles_both_next_gen()

public static function core_handles_both_next_gen(): bool

Check if WordPress core (7.1+) natively handles both WebP and AVIF generation.

Return: bool — True if core can generate both WebP and AVIF natively.

Tags: @since 2.0.0

Source: includes/Images/class-img-converter.php, line 150

public get_format()

public function get_format(): string

Get the current conversion format.

Return: string — The format (\’webp\’, \’avif\’, \’both\’, or \’none\’).

Tags: @since 2.0.0

Source: includes/Images/class-img-converter.php, line 163

private resolve_encode_quality()

private function resolve_encode_quality(string $mime, int $fallback, array=array() $size): int

Resolve the encode quality for an output MIME type.

ParameterTypeDefaultDescription
$mimestring—The output MIME type (e.g. \’image/webp\’).
$fallbackint—Fallback quality (1-100) used when no core API provides a value.
$sizearray=array()—Optional dimensions of the source image (\’width\’/\’height\’).

Return: int — The encode quality to use (1-100).

Tags: @since 2.0.0

Source: includes/Images/class-img-converter.php, line 192

private resolve_output_format()

private function resolve_output_format(string $source_image, string $requested_format): string

Resolve the effective target format using core\’s centralized `image_editor_output_format` mapping when available.

ParameterTypeDefaultDescription
$source_imagestring—Filesystem path to the source image.
$requested_formatstring—The format requested by the plugin (\’webp\’, \’avif\’, or \’both\’).

Return: string — The effective target format (\’webp\’, \’avif\’, \’both\’, or \’none\’).

Tags: @since 2.0.0

Source: includes/Images/class-img-converter.php, line 234

private get_source_image_dimensions()

private function get_source_image_dimensions(string $source_image): array

Infer the dimensions of a source image from its file name.

ParameterTypeDefaultDescription
$source_imagestring—Filesystem path to the source image.

Return: array — The dimensions array (\’width\’/\’height\’), empty for full-size originals.

Tags: @since 2.0.0

Source: includes/Images/class-img-converter.php, line 272

publicstatic get_smart_quality_size_offset()

public static function get_smart_quality_size_offset(array $size): int

Size-aware quality offset for the smart-quality heuristic.

ParameterTypeDefaultDescription
$sizearray—Optional source dimensions (\’width\’/\’height\’). Empty means full-size original.

Return: int — Offset in `[-10, +10]`.

Tags: @since 2.3.0

Source: includes/Images/class-img-converter.php, line 297

publicstatic is_hero_candidate_image()

public static function is_hero_candidate_image(string $source_image): bool

Whether a source image looks like a hero/LCP candidate.

ParameterTypeDefaultDescription
$source_imagestring—Filesystem path to the source image.

Return: bool — True when the file looks like a hero candidate.

Tags: @since 2.3.0

Source: includes/Images/class-img-converter.php, line 335

publicstatic get_smart_quality_role_offset()

public static function get_smart_quality_role_offset(string=\'\' $source_image): int

Role-aware quality offset for the smart-quality heuristic.

ParameterTypeDefaultDescription
$source_imagestring=\'\'—Filesystem path to the source image.

Return: int — Offset in `[-10, +10]`.

Tags: @since 2.3.0

Source: includes/Images/class-img-converter.php, line 368

publicstatic apply_smart_quality_offsets()

public static function apply_smart_quality_offsets(int $base, int $size_offset, int $role_offset): int

Apply size + role offsets to a base quality with bounded delta.

ParameterTypeDefaultDescription
$baseint—Base quality (1-100) before offsets.
$size_offsetint—Size-aware offset (`[-10, +10]`).
$role_offsetint—Role-aware offset (`[-10, +10]`).

Return: int — Adjusted quality (1-100) within ±10 of `$base`.

Tags: @since 2.3.0

Source: includes/Images/class-img-converter.php, line 404

publicstatic order_queue_hero_first()

public static function order_queue_hero_first(array $attachment_ids): array

Order attachment IDs hero-first for the conversion queue.

ParameterTypeDefaultDescription
$attachment_idsarray—Attachment IDs in scan order.

Return: array — Reordered IDs with hero candidates first.

Tags: @since 2.3.0

Source: includes/Images/class-img-converter.php, line 427

publicstatic is_avif_encoder_available()

public static function is_avif_encoder_available(): bool

Whether an AVIF encoder is available on this host.

Return: bool — True when AVIF encoding is supported.

Tags: @since 2.0.0

Source: includes/Images/class-img-converter.php, line 472

publicstatic is_imagick_avif_available()

public static function is_imagick_avif_available(): bool

Whether Imagick alone can encode AVIF on this host.

Return: bool — True when Imagick reports an AVIF delegate.

Tags: @since 2.2.0

Source: includes/Images/class-img-converter.php, line 521

public encode_avif_via_imagick()

public function encode_avif_via_imagick(string $source_image, string $dest_path, int $quality, int=0 $max_edge): bool

Encode a source image to AVIF via Imagick.

ParameterTypeDefaultDescription
$source_imagestring—Filesystem path to the source image.
$dest_pathstring—Filesystem path for the `.avif` output.
$qualityint—Encode quality (1-100).
$max_edgeint=0—Optional longest-edge cap in pixels (`0` disables).

Return: bool — True on success, false on any failure.

Tags: @since 2.2.0

Source: includes/Images/class-img-converter.php, line 578

public get_skip_small_threshold()

public function get_skip_small_threshold(): int

Get the skip-small byte threshold for image conversion.

Return: int — Threshold in bytes (>= 0).

Tags: @since 2.0.0

Source: includes/Images/class-img-converter.php, line 676

public should_skip_small_file()

public function should_skip_small_file(string $path): bool

Whether a source file should be skipped as too small to convert.

ParameterTypeDefaultDescription
$pathstring—Filesystem path to the source image.

Return: bool — True when the file is at or under the threshold.

Tags: @since 2.0.0

Source: includes/Images/class-img-converter.php, line 707

public get_longest_edge_cap()

public function get_longest_edge_cap(): int

Resolve the longest-edge downscale cap in pixels.

Return: int — Cap in pixels (>= 0). `0` means disabled.

Tags: @since 2.0.0

Source: includes/Images/class-img-converter.php, line 739

public get_max_source_pixels()

public function get_max_source_pixels(): int

Maximum source pixel count decodable before GD risks a fatal OOM.

Return: int — Pixel budget (>= 1).

Tags: @since 2.0.0

Source: includes/Images/class-img-converter.php, line 777

protected get_php_memory_limit_bytes()

protected function get_php_memory_limit_bytes(): int

Parse PHP\’s memory_limit into bytes.

Return: int — Bytes, or `0` when unlimited or unknown.

Tags: @since 2.0.0

Source: includes/Images/class-img-converter.php, line 806

publicstatic is_path_in_allowlist()

public static function is_path_in_allowlist(string $path): bool

Check whether an absolute filesystem path stays inside the plugin\’s read allowlist.

ParameterTypeDefaultDescription
$pathstring—Absolute filesystem path to check.

Return: bool — True when the path is inside the allowlist.

Tags: @since 2.0.0

Source: includes/Images/class-img-converter.php, line 843

publicstatic is_safe_delete_path()

public static function is_safe_delete_path(string $path): bool

Check whether a path is safe to unlink (strict delete allowlist).

ParameterTypeDefaultDescription
$pathstring—Absolute filesystem path proposed for deletion.

Return: bool — True when deletion is allowed.

Tags: @since 2.0.0

Source: includes/Images/class-img-converter.php, line 904

publicstatic is_safe_write_path()

public static function is_safe_write_path(string $path): bool

Check whether a conversion output path is safe to write.

ParameterTypeDefaultDescription
$pathstring—Absolute filesystem path proposed for writing.

Return: bool — True when writing is allowed.

Tags: @since 2.0.0

Source: includes/Images/class-img-converter.php, line 958

publicstatic is_allowed_source_mime()

public static function is_allowed_source_mime(string $mime): bool

Whether a detected source MIME may reach an image decoder (audit #1411).

ParameterTypeDefaultDescription
$mimestring—Detected MIME (e.g. from getimagesize()).

Return: bool — True when the MIME is a decodable bitmap type.

Tags: @since 2.2.0

Source: includes/Images/class-img-converter.php, line 994

public exceeds_pixel_budget()

public function exceeds_pixel_budget(int $width, int $height, int=4 $channels): bool

Channels-aware pre-decode pixel-budget check against the PHP memory limit.

ParameterTypeDefaultDescription
$widthint—Source width in pixels.
$heightint—Source height in pixels.
$channelsint=4—Channel count (clamped to 1-4, default 4).

Return: bool — True when the image exceeds the budget and must be skipped.

Tags: @since 2.0.0

Source: includes/Images/class-img-converter.php, line 1015

private get_source_channels()

private function get_source_channels(): int

Decode channel count for the pixel-budget estimate.

Return: int — Channel count (always 4, conservative for GD truecolor).

Tags: @since 2.0.0

Source: includes/Images/class-img-converter.php, line 1047

public maybe_downscale_gd_image()

public function maybe_downscale_gd_image($image, int $width, int $height)

Downscale a decoded GD image when its longest edge exceeds the cap.

ParameterTypeDefaultDescription
$imageresource|\\GdImage—Decoded GD image resource.
$widthint—Source width in pixels.
$heightint—Source height in pixels.

Return: resource|\\GdImage — Scaled image when it shrinks output, else the original.

Tags: @since 2.0.0

Source: includes/Images/class-img-converter.php, line 1069

public maybe_downscale_gd_image_to_edge()

public function maybe_downscale_gd_image_to_edge($image, int $width, int $height, int $edge)

Downscale a decoded GD image to an explicit longest edge.

ParameterTypeDefaultDescription
$imageresource|\\GdImage—Decoded GD image resource.
$widthint—Source width in pixels.
$heightint—Source height in pixels.
$edgeint—Target longest edge in pixels.

Return: resource|\\GdImage — Scaled image when it shrinks output, else the original.

Tags: @since 2.2.0

Source: includes/Images/class-img-converter.php, line 1151

public get_memory_safe_edge_px()

public function get_memory_safe_edge_px(int $width, int $height, int=4 $channels): int

Memory-safe longest edge for an over-budget source image.

ParameterTypeDefaultDescription
$widthint—Source width in pixels.
$heightint—Source height in pixels.
$channelsint=4—Channel count (clamped to 1-4, default 4).

Return: int — Safe longest edge in pixels, or `0` when no fallback is needed/unavailable.

Tags: @since 2.2.0

Source: includes/Images/class-img-converter.php, line 1232

protected apply_imagick_memory_guard()

protected function apply_imagick_memory_guard($imagick): void

Apply best-effort Imagick memory guard resource limits.

ParameterTypeDefaultDescription
$imagick\\Imagick—Imagick instance to guard.

Return: void.

Tags: @since 2.2.0

Source: includes/Images/class-img-converter.php, line 1348

protected decode_overbudget_image_via_imagick()

protected function decode_overbudget_image_via_imagick(string $source, int $safe_edge)

Decode an over-budget still via Imagick thumbnail without a full-size GD decode.

ParameterTypeDefaultDescription
$sourcestring—Absolute filesystem path to the source image.
$safe_edgeint—Memory-safe longest edge in pixels.

Return: resource|\\GdImage|null — Decoded GD image on success, null on any failure.

Tags: @since 2.2.0

Source: includes/Images/class-img-converter.php, line 1391

public get_smart_quality()

public function get_smart_quality(string $mime, array=array() $size, string=\'\' $source_image): int

Resolve the smart encode quality for an output MIME type.

ParameterTypeDefaultDescription
$mimestring—Output MIME type (e.g. \’image/avif\’).
$sizearray=array()—Optional source dimensions (\’width\’/\’height\’).
$source_imagestring=\'\'—Optional source filesystem path for size/role offsets.

Return: int — The encode quality to use (1-100).

Tags: @since 2.0.0

Source: includes/Images/class-img-converter.php, line 1490

public is_smart_compress_enabled()

public function is_smart_compress_enabled(): bool

Whether the size-compare smart-compress pipeline is enabled.

Return: bool — True when oversized siblings should be discarded.

Tags: @since 2.2.0

Source: includes/Images/class-img-converter.php, line 1594

public should_discard_oversized_sibling()

public function should_discard_oversized_sibling(string $source_path, string $sibling_path): bool

Whether a converted sibling should be discarded for exceeding its source.

ParameterTypeDefaultDescription
$source_pathstring—Filesystem path to the source image.
$sibling_pathstring—Filesystem path to the converted sibling.

Return: bool — True when the sibling must be discarded.

Tags: @since 2.2.0

Source: includes/Images/class-img-converter.php, line 1623

public discard_oversized_sibling()

public function discard_oversized_sibling(string $source_path, string $sibling_path): bool

Discard a converted sibling that exceeds its source byte size.

ParameterTypeDefaultDescription
$source_pathstring—Filesystem path to the source image.
$sibling_pathstring—Filesystem path to the converted sibling.

Return: bool — True when the sibling was discarded.

Tags: @since 2.2.0

Source: includes/Images/class-img-converter.php, line 1673

private record_encoded_sibling()

private function record_encoded_sibling(string $source_image, string $sibling_path, string $type, bool& $success): void

Record a freshly encoded (or pre-existing) sibling as completed, discarding it first when it exceeds its source byte size.

ParameterTypeDefaultDescription
$source_imagestring—Filesystem path to the source image.
$sibling_pathstring—Filesystem path to the converted sibling.
$typestring—Conversion type (\’webp\’ or \’avif\’).
$successbool&—Conversion success flag, set to false when discarded.

Return: void.

Tags: @since 2.2.0

Source: includes/Images/class-img-converter.php, line 1719

private is_gain_map_image()

private function is_gain_map_image(string $source_image): bool

Whether the source embeds an UltraHDR gain map.

ParameterTypeDefaultDescription
$source_imagestring—Filesystem path to the candidate image.

Return: bool — True when an hdrgm XMP marker is present.

Tags: @since 2.0.0

Source: includes/Images/class-img-converter.php, line 1741

public convert_image()

public function convert_image(string $source_image, string=\'webp\' $format, int=-1 $quality): bool

Convert a source image into WebP and/or AVIF and record conversion status.

ParameterTypeDefaultDescription
$source_imagestring—Filesystem path to the source image.
$formatstring=\'webp\'—One of \’webp\’, \’avif\’, or \’both\’ indicating desired target format(s).
$qualityint=-1—Quality for the converted image (0-100). Use -1 to let underlying library choose defaults.

Return: bool — `true` if the conversion(s) for the requested format(s) completed successfully, `false` otherwise.

Tags: @since 1.0.0

Source: includes/Images/class-img-converter.php, line 1770

private convert_palette_to_truecolor()

private function convert_palette_to_truecolor($image)

Convert an image palette to true color if it is not already in true color.

ParameterTypeDefaultDescription
$image\\GdImage—The image resource.

Return: \\GdImage — The true color image resource.

Tags: @since 1.0.0

Source: includes/Images/class-img-converter.php, line 2469

private extract_dominant_color()

private function extract_dominant_color($image): string

Extract dominant color from a GD image resource.

ParameterTypeDefaultDescription
$image\\GdImage—The GD image resource.

Return: string — Hex color string (e.g. \’#aabbcc\’).

Tags: @since 2.0.0

Source: includes/Images/class-img-converter.php, line 2503

private generate_lqip()

private function generate_lqip($image): string

Generate a Low-Quality Image Placeholder (LQIP) from a GD image resource.

ParameterTypeDefaultDescription
$image\\GdImage—The GD image resource.

Return: string — Base64-encoded data URI, or empty string on failure.

Tags: @since 2.0.0

Source: includes/Images/class-img-converter.php, line 2554

private store_placeholder_data()

private function store_placeholder_data(string $rel_path, string $dominant_color, string $lqip): void

Store dominant color and LQIP data for an image atomically via the existing deferred-commit pattern (wppo_img_info).

ParameterTypeDefaultDescription
$rel_pathstring—The relative image path (ABSPATH-stripped).
$dominant_colorstring—Hex color string.
$lqipstring—LQIP data URI (empty string if not generated).

Return: void.

Tags: @since 2.0.0

Source: includes/Images/class-img-converter.php, line 2638

private store_placeholder_data_batch()

private function store_placeholder_data_batch(array $batch): void

Store placeholder data for multiple rel_paths in one atomic update.

ParameterTypeDefaultDescription
$batcharray——

Return: void.

Tags: @since 2.0.0

Source: includes/Images/class-img-converter.php, line 2679

publicstatic get_placeholder_info()

public static function get_placeholder_info(): array

Get placeholder data (dominant_color, lqip) from the shared wppo_img_info option.

Return: array{dominant_color: — array<string, string>, lqip: array<string, string>}.

Tags: @since 2.0.0

Source: includes/Images/class-img-converter.php, line 2732

publicstatic clean_placeholder_on_delete()

public static function clean_placeholder_on_delete(int $post_id): void

Clean up placeholder data (dominant_color, lqip) when an attachment is deleted.

ParameterTypeDefaultDescription
$post_idint—The attachment ID.

Return: void.

Tags: @since 2.0.0

Source: includes/Images/class-img-converter.php, line 2761

private is_animated_webp()

private function is_animated_webp($file)

Check if a WebP image is animated.

ParameterTypeDefaultDescription
$filestring—Path to the WebP file.

Return: bool — True if the WebP image is animated, false otherwise.

Tags: @since 1.0.0

Source: includes/Images/class-img-converter.php, line 2848

publicstatic get_img_path()

public static function get_img_path(string $source_image, string=\'webp\' $format): string

Compute the filesystem path where a converted image (WebP or AVIF) should be stored.

ParameterTypeDefaultDescription
$source_imagestring—Absolute filesystem path or URL of the source image.
$formatstring=\'webp\'—Desired output format; typically \’webp\’ or \’avif\’.

Return: string — Filesystem path where the converted image should be saved, or the original $source_image if a safe local path cannot be determined.

Tags: @since 1.0.0

Source: includes/Images/class-img-converter.php, line 2892

publicstatic get_img_url()

public static function get_img_url(string $source_image, string=\'webp\' $format): string

Get the URL of the converted image.

ParameterTypeDefaultDescription
$source_imagestring—The source image URL.
$formatstring=\'webp\'—The desired format (\’webp\’ or \’avif\’).

Return: string — The URL of the converted image.

Tags: @since 1.0.0

Source: includes/Images/class-img-converter.php, line 2995

public convert_image_to_next_gen_format()

public function convert_image_to_next_gen_format($metadata, $attachment_id)

Convert uploaded images to WebP or AVIF format upon attachment upload.

ParameterTypeDefaultDescription
$metadataarray—The attachment metadata.
$attachment_idint—The attachment ID.

Return: array|\\WP_Error — The modified attachment metadata, or WP_Error on failure.

Tags: @since 1.0.0

Source: includes/Images/class-img-converter.php, line 3027

private is_client_side_media_processing()

private function is_client_side_media_processing(): bool

Whether WP 7.1+ client-side media processing is enabled.

Return: bool — True if client-side media processing is enabled.

Tags: @since 1.9.0 · @since 2.0.0 Document wasm gating and HDR preservation.

Source: includes/Images/class-img-converter.php, line 3128

private maybe_extract_placeholder_for_upload()

private function maybe_extract_placeholder_for_upload(array $metadata, int $attachment_id): void

Extract placeholder data for a new upload when server-side conversion is skipped (WP 7.1+ client-side processing, or WP 6.7+ core-native next-gen generation).

ParameterTypeDefaultDescription
$metadataarray—The attachment metadata.
$attachment_idint—The attachment ID.

Return: void.

Tags: @since 1.9.0 · @since 2.0.0 Add HEIC early-exit and double-fire idempotency guard.

Source: includes/Images/class-img-converter.php, line 3179

private store_placeholder_data_for_upload()

private function store_placeholder_data_for_upload(array $metadata, int $attachment_id): void

Store dominant-color and LQIP placeholder data for a new upload when server-side conversion is skipped (WP 7.1+ client-side media processing, or WP 6.7+ core-native next-gen generation).

ParameterTypeDefaultDescription
$metadataarray—The attachment metadata.
$attachment_idint—The attachment ID.

Return: void.

Tags: @since 1.9.0

Source: includes/Images/class-img-converter.php, line 3279

public maybe_serve_next_gen_image()

public function maybe_serve_next_gen_image($image)

Serve WebP or AVIF images if supported by the browser.

ParameterTypeDefaultDescription
$imagearray—The image source array.

Return: array — Modified image source with WebP/AVIF if applicable, or original image if not.

Tags: @since 1.0.0

Source: includes/Images/class-img-converter.php, line 3463

private should_suppress_re_queueing()

private function should_suppress_re_queueing(): bool

Whether re-queueing of missing conversions should be suppressed on the frontend hot path.

Return: bool — True when re-queueing should be suppressed.

Tags: @since 1.9.0

Source: includes/Images/class-img-converter.php, line 3522

public update_conversion_status()

public function update_conversion_status($img_path, =\'completed\' $status, =\'webp\' $type)

Update the conversion status of an image.

ParameterTypeDefaultDescription
$img_pathstring—The image path.
$status=\'completed\'—The status to update (\’completed\’, \’failed\’, etc.).
$type=\'webp\'—The image format type (\’webp\’, \’avif\’).

Tags: @since 1.0.0

Source: includes/Images/class-img-converter.php, line 3534

privatestatic measure_conversion_sizes()

private static function measure_conversion_sizes(string $img_path, string $type): ?array

Measure original vs converted byte sizes for a completed conversion.

ParameterTypeDefaultDescription
$img_pathstring—Relative source path (ABSPATH-stripped).
$typestring—Conversion type (\’webp\’ or \’avif\’).

Return: array|null — { original: int, converted: int } or null when either file cannot be measured.

Tags: @since 2.0.0

Source: includes/Images/class-img-converter.php, line 3607

publicstatic get_savings_summary()

public static function get_savings_summary(?array=null $img_info): array

Aggregate recorded conversion sizes into a savings summary.

ParameterTypeDefaultDescription
$img_info?array=null—Pre-read img info (null = read here, avoids a second unserialize).

Return: array{original_bytes: — int, converted_bytes: int, saved_bytes: int, images_counted: int}.

Tags: @since 2.0.0

Source: includes/Images/class-img-converter.php, line 3638

publicstatic queue_unconverted_library_images()

public static function queue_unconverted_library_images(array $formats, int=50 $limit): int

Discover library images missing next-gen versions and queue them.

ParameterTypeDefaultDescription
$formatsarray—Conversion formats to ensure (\’webp\’, \’avif\’).
$limitint=50—Maximum attachments inspected per window.

Return: int — Number of files newly queued.

Tags: @since 2.0.0 Cursor pagination via wppo_img_scan_cursor.

Source: includes/Images/class-img-converter.php, line 3689

publicstatic add_img_into_queue()

public static function add_img_into_queue($img_path, =\'webp\' $type)

Add an image to the conversion queue.

ParameterTypeDefaultDescription
$img_pathstring—The image path.
$type=\'webp\'—The image format type (\’webp\’, \’avif\’).

Tags: @since 1.0.0

Source: includes/Images/class-img-converter.php, line 3811

publicstatic get_img_info()

public static function get_img_info(): array

Returns the current image info from the database.

Return: array.

Tags: @since 1.1.4

Source: includes/Images/class-img-converter.php, line 3881

publicstatic set_img_info()

public static function set_img_info(array $img_info): void

Manually updates the image info database option.

ParameterTypeDefaultDescription
$img_infoarray—The new image info array.

Return: void.

Tags: @since 1.1.4

Source: includes/Images/class-img-converter.php, line 3916

publicstatic clear_completed_formats()

public static function clear_completed_formats(): void

Atomically clears completed webp and avif entries from the image info option.

Return: void.

Tags: @since 1.4.0

Source: includes/Images/class-img-converter.php, line 3928

privatestatic update_img_info_atomic()

private static function update_img_info_atomic(callable $callback): void

Performs an atomic-like merge-aware update of the image info option.

ParameterTypeDefaultDescription
$callbackcallable—The callback that receives the current info and returns the updated info.

Return: void.

Tags: @since 1.1.4

Source: includes/Images/class-img-converter.php, line 3955

publicstatic commit_img_info()

public static function commit_img_info(): void

Commits deferred image info state to the database on shutdown.

Return: void.

Tags: @since 1.4.0

Source: includes/Images/class-img-converter.php, line 3970

publicstatic invalidate_img_info_cache()

public static function invalidate_img_info_cache(): void

Invalidate the image info cache by bumping the salt.

Return: void.

Tags: @since 2.0.0

Source: includes/Images/class-img-converter.php, line 4044

publicstatic migrate_img_info_autoload()

public static function migrate_img_info_autoload(): void

Forces the \’wppo_img_info\’ option to be non-autoloading.

Return: void.

Tags: @since 1.5.1

Source: includes/Images/class-img-converter.php, line 4061

Hooks

Hooks referenced in includes/Images/class-img-converter.php:

HookTypeLineNotes
wppo_skip_small_threshold_bytesfilter685@param ×1
wppo_max_longest_edge_pxfilter748@param ×1
wppo_max_source_pixelsfilter785@param ×1
wppo_memory_safe_edge_pxfilter1315@param ×4
wppo_smart_qualityfilter1499@param ×1
wppo_smart_quality_valuefilter1548@param ×4
wppo_smart_pipeline_enabledfilter1603@param ×1
wppo_discard_oversized_siblingfilter1653@param ×3
wppo_convert_gain_map_imagesfilter1819—
wppo_filesize_limit_bytesfilter1885—
wppo_max_dimensionsfilter1961—
wppo_filesize_limit_bytesfilter3289—
wppo_max_dimensionsfilter3346—
wppo_placeholder_string_fallback_max_bytesfilter3397—
wppo_convertible_image_extensionsfilter3766—
wppo_convertible_image_extensionsfilter3828@param ×1