Recent

Converterclass

Converter

Creates reversible sidecar images without modifying originals.

Namespace: WebberZone\Image_Optimizer
Since: 1.0.0
Source: includes/class-converter.php line 22

Methods

get_args() static

Resolve the conversion arguments, layering overrides over the settings.

Since: 1.0.0
Line: 33

static public function get_args( array $overrides = ... ): array;
Type Name Description
array $overrides

Returns: array — mixed> Arguments.

convert_attachment() static

Convert every served attachment file, excluding the unserved big-image original.

Since: 1.0.0
Line: 76

static public function convert_attachment( int $attachment_id, array $overrides = ..., ?array $meta = ... ): array{files:;
Type Name Description
int $attachment_id Attachment ID.
array $overrides
?array $meta

Returns: array{files: — int, converted: int, skipped: int, failed: int, source: int, saved: int, errors: array<int, string>}|\WP_Error Summary or error.

convert_next_file() static

Convert one unsettled attachment file per call for bounded progress.

Force is unsupported because it would repeatedly select the first file.

Since: 1.0.0
Line: 134

static public function convert_next_file( int $attachment_id, array $overrides = ... ): array{done:;
Type Name Description
int $attachment_id Attachment ID.
array $overrides

Returns: array{done: — bool, index: int, total: int}|\WP_Error Progress, or error.

convert_file() static

Convert one source file into every requested format.

Since: 1.0.0
Line: 303

static public function convert_file( string $path, array $args, array $existing = ... ): array;
Type Name Description
string $path Absolute path to the source image.
array $args
array $existing

Returns: array — mixed> File record.

get_attachment_files() static

List the deliverable files belonging to an attachment.

Since: 1.0.0
Line: 416

static public function get_attachment_files( int $attachment_id, ?array $meta = ... ): array;
Type Name Description
int $attachment_id Attachment ID.
?array $meta

Returns: array — string> Basename to absolute path.

is_excluded() static

Whether a file matches one of the configured exclusion fragments.

Matching is done against the path relative to the uploads directory so that a fragment such as 2019/07 behaves the same on every install.

Since: 1.0.0
Line: 497

static public function is_excluded( string $path ): bool;
Type Name Description
string $path Absolute file path.

Returns: bool — True when the file should be left alone.

get_enabled_sizes() static

Get the image sizes selected in the settings.

Since: 1.0.0
Line: 545

static public function get_enabled_sizes(  ): ?array;

Returns: ?array — string>|null Size names, or null when every size is enabled.

is_convertible_attachment() static

Whether an attachment is an image the plugin can convert.

Since: 1.0.0
Line: 563

static public function is_convertible_attachment( int $attachment_id ): bool;
Type Name Description
int $attachment_id Attachment ID.

Returns: bool — True when convertible.

delete_sidecars() static

Delete every sidecar belonging to an attachment and clear its record.

Since: 1.0.0
Line: 599

static public function delete_sidecars( int $attachment_id ): int;
Type Name Description
int $attachment_id Attachment ID.

Returns: int — Number of files deleted.