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: 82
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.
get_progress() static
Get an interrupted background conversion.
Since: 1.1.0
Line: 94
static public function get_progress( int $attachment_id ): array;
| Type | Name | Description |
|---|---|---|
int |
$attachment_id |
Attachment ID. |
Returns: array — int, updated: int, files: array<string, array<string, mixed>>, context?: string, processed: array<int, string>, …} Record.
empty_record() static
An empty record.
Since: 1.0.0
Line: 138
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: 155
static public function set( int $attachment_id, array $record ): void;
| Type | Name | Description |
|---|---|---|
int |
$attachment_id |
Attachment ID. |
array |
$record |
Returns: void
set_byte_totals() static
Store the record’s byte totals as numeric meta so the library can be summed in SQL.
Since: 1.1.2
Line: 172
static public function set_byte_totals( int $attachment_id, array $record ): void;
| Type | Name | Description |
|---|---|---|
int |
$attachment_id |
Attachment ID. |
array |
$record |
Returns: void
set_progress() static
Store an interrupted background conversion.
Since: 1.1.0
Line: 194
static public function set_progress( int $attachment_id, array $record, string $context, array $processed ): void;
| Type | Name | Description |
|---|---|---|
int |
$attachment_id |
Attachment ID. |
array |
$record |
|
string |
$context |
Conversion context fingerprint. |
array |
$processed |
Returns: void
delete_progress() static
Remove an interrupted background conversion.
Since: 1.1.0
Line: 211
static public function delete_progress( int $attachment_id ): void;
| Type | Name | Description |
|---|---|---|
int |
$attachment_id |
Attachment ID. |
Returns: void
delete() static
Remove the conversion record for an attachment.
Since: 1.0.0
Line: 223
static public function delete( int $attachment_id ): void;
| Type | Name | Description |
|---|---|---|
int |
$attachment_id |
Attachment ID. |
Returns: void
count_retryable() static
Count the format entries that were skipped or failed.
Since: 1.1.2
Line: 241
static public function count_retryable( array $record ): int;
| Type | Name | Description |
|---|---|---|
array |
$record |
Returns: int — Number of retryable entries.
clear_retryable() static
Forget skipped and failed entries so the next pass attempts them again.
Since: 1.1.2
Line: 266
static public function clear_retryable( int $attachment_id ): int;
| Type | Name | Description |
|---|---|---|
int |
$attachment_id |
Attachment ID. |
Returns: int — Number of entries cleared.
get_file() static
Get the record for a single source file within an attachment.
Since: 1.0.0
Line: 300
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: 315
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: 332
static public function converted_entry( int $bytes, ?int $quality = ..., bool $reduced = ..., ?string $fingerprint = ... ): array;
| Type | Name | Description |
|---|---|---|
int |
$bytes |
Sidecar size in bytes. |
int|null |
$quality |
Effective lossy quality, when known. |
bool |
$reduced |
Whether the copy needed the lower-quality retry. |
string|null |
$fingerprint |
Fingerprint of the settings that produced the copy, when known. |
Returns: array — int, quality?: int, reduced?: bool, fp?: string} Entry.
skipped_entry() static
Build the record entry for a file that was deliberately not converted.
Since: 1.0.0
Line: 360
static public function skipped_entry( string $reason, ?int $quality = ... ): array;
| Type | Name | Description |
|---|---|---|
string |
$reason |
Machine-readable reason. |
int|null |
$quality |
Final lossy quality attempted, when applicable. |
Returns: array — string, quality?: int} Entry.
error_entry() static
Build the record entry for a failed conversion.
Since: 1.0.0
Line: 378
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: 390
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, reduced: int, formats: array<string, int>} Totals.
summarise() static
Summarise the bytes stored and saved for a record.
Since: 1.1.2
Line: 402
static public function summarise( array $record ): array;
| Type | Name | Description |
|---|---|---|
array |
$record |
Returns: array — int, converted: int, saved: int, files: int, reduced: int, formats: array<string, int>} Totals.
is_outdated() static
Whether any optimized copy was made with settings other than the current ones.
A copy with no fingerprint predates tracking and is never reported outdated.
Since: 1.2.0
Line: 460
static public function is_outdated( array $record, array $args, string $mime ): bool;
| Type | Name | Description |
|---|---|---|
array |
$record |
|
array |
$args |
|
string |
$mime |
Source MIME type. |
Returns: bool — True when at least one copy is outdated.
delete_sidecar_records() static
Drop disposable sidecar results while retaining original recovery summaries.
Line: 487
static public function delete_sidecar_records( int $attachment_id ): void;
| Type | Name | Description |
|---|---|---|
int |
$attachment_id |
Attachment ID. |
Returns: void