Recent

Attachment_Metaclass

Attachment_Meta

Stores per-file conversion results keyed by basename for each attachment.

Namespace: WebberZone\Image_Optimizer
Since: 1.0.0
Source: includes/class-attachment-meta.php line 21

Methods

get() static

Get the conversion record for an attachment.

Since: 1.0.0
Line: 47

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

Returns: array — int, updated: int, files: array<string, array<string, mixed>>} Record.

empty_record() static

An empty record.

Since: 1.0.0
Line: 75

static public function empty_record(  ): array;

Returns: array — int, updated: int, files: array<string, array<string, mixed>>} Record.

set() static

Store the conversion record for an attachment.

Since: 1.0.0
Line: 92

static public function set( int $attachment_id, array $record ): void;
Type Name Description
int $attachment_id Attachment ID.
array $record

Returns: void

delete() static

Remove the conversion record for an attachment.

Since: 1.0.0
Line: 107

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

Returns: void

get_file() static

Get the record for a single source file within an attachment.

Since: 1.0.0
Line: 120

static public function get_file( int $attachment_id, string $basename ): array;
Type Name Description
int $attachment_id Attachment ID.
string $basename Source file basename.

Returns: array — mixed> File record, empty when unknown.

is_converted() static

Whether a usable sidecar was produced for a file and format.

Since: 1.0.0
Line: 135

static public function is_converted( array $file_record, string $format ): bool;
Type Name Description
array $file_record
string $format Target format slug.

Returns: bool — True when a sidecar should be served.

converted_entry() static

Build the record entry for a successful conversion.

Since: 1.0.0
Line: 147

static public function converted_entry( int $bytes ): array;
Type Name Description
int $bytes Sidecar size in bytes.

Returns: array — int} Entry.

skipped_entry() static

Build the record entry for a file that was deliberately not converted.

Since: 1.0.0
Line: 159

static public function skipped_entry( string $reason ): array;
Type Name Description
string $reason Machine-readable reason.

Returns: array — string} Entry.

error_entry() static

Build the record entry for a failed conversion.

Since: 1.0.0
Line: 171

static public function error_entry( string $message ): array;
Type Name Description
string $message Error message.

Returns: array — string} Entry.

get_totals() static

Summarise the bytes stored and saved for an attachment.

Since: 1.0.0
Line: 183

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

Returns: array — int, converted: int, saved: int, files: int, formats: array<string, int>} Totals.