Recent

Converterclass

Converter

Creates sidecars after optional, reversible original-file optimization.

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: 53

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

Returns: array — mixed> Arguments.

fingerprint() static

Fingerprint the settings that decide how a source of this type is encoded.

Since: 1.2.0
Line: 100

static public function fingerprint( string $format, array $args, string $mime, ?int $effective_quality = ..., bool $reduced = ... ): string;
Type Name Description
string $format Target format slug.
array $args
string $mime Source MIME type.
int|null $effective_quality Effective quality of the stored copy.
bool $reduced Whether the lower-quality retry produced it.

Returns: string — Short fingerprint.

get_quality() static

The quality configured for a format.

Since: 1.1.0
Line: 123

static public function get_quality( string $format ): int;
Type Name Description
string $format Target format slug.

Returns: int — Quality between 1 and 100.

convert_attachment() static

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

Since: 1.0.0
Line: 142

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, reduced: int, source: int, saved: int, errors: array<int, string>, complete: bool}|\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: 305

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: 606

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: 979

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: 1060

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: 1108

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: 1126

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: 1162

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

Returns: int — Number of files deleted.