Original_Optimizer
Coordinates source mutations and their recovery metadata.
Namespace: WebberZone\Image_Optimizer
Since: 1.2.0
Source: includes/class-original-optimizer.php line 23
Methods
locked() static
Run a conversion under the same lock as source replacement and restore.
Line: 54
static public function locked( int $id, callable $callback ): mixed;
| Type | Name | Description |
|---|---|---|
int |
$id |
Attachment ID. |
callable |
$callback |
Conversion. |
Returns: mixed — Conversion result.
settings() static
Get effective settings for fingerprinting and processing.
Line: 66
static public function settings( ): array;
Returns: array — Settings.
process_file() static
Optimize a served source before its sidecars are created.
Line: 83
static public function process_file( int $id, string $path ): array;
| Type | Name | Description |
|---|---|---|
int |
$id |
Attachment ID. |
string |
$path |
Served source. |
Returns: array — Original result.
note_written() static
Record a file written by a core image editor in this request.
Line: 228
static public function note_written( string $path ): void;
| Type | Name | Description |
|---|---|---|
string |
$path |
Saved file. |
Returns: void
retire_regenerated() static
Retire backups of sub-sizes that core rewrote during a metadata update.
The regenerated file, including a rebuilt -scaled main file, is the new source; unannounced writes are untouched. Caller should hold the attachment lock.
Line: 245
static public function retire_regenerated( int $id, array $meta ): void;
| Type | Name | Description |
|---|---|---|
int |
$id |
Attachment ID. |
array |
$meta |
Incoming attachment metadata. |
Returns: void
invalidate_sidecars() static
Delete only recorded sidecars after source replacement.
Line: 307
static public function invalidate_sidecars( int $id, string $path ): void;
| Type | Name | Description |
|---|---|---|
int |
$id |
Attachment ID. |
string |
$path |
Served source. |
Returns: void
reconcile_metadata() static
Reconcile dimensions and file sizes only for files in the recovery manifest.
Line: 333
static public function reconcile_metadata( int $id, array $meta ): array;
| Type | Name | Description |
|---|---|---|
int |
$id |
Attachment ID. |
array |
$meta |
Attachment metadata. |
Returns: array — Updated metadata.
update_metadata() static
Persist dimensions without recursively invoking conversion.
Line: 368
static public function update_metadata( int $id ): bool;
| Type | Name | Description |
|---|---|---|
int |
$id |
Attachment ID. |
Returns: bool — Whether metadata is persisted.
restore() static
Restore every backup for an attachment, retaining failures for another attempt.
Line: 392
static public function restore( int $id, bool $queue = ... ): int|\WP_Error;
| Type | Name | Description |
|---|---|---|
int |
$id |
Attachment ID. |
bool |
$queue |
Whether to queue sidecar regeneration. |
Returns: int|\WP_Error — Restored count or error.
needs_processing() static
Determine whether settled sidecars still need the original-file stage.
Line: 464
static public function needs_processing( int $id, array $record, string $path ): bool;
| Type | Name | Description |
|---|---|---|
int |
$id |
Attachment ID. |
array |
$record |
File record. |
string |
$path |
Source path. |
Returns: bool — Whether original settings have changed.
filter_srcset() static
Keep oversized legacy thumbnails out of generated responsive candidates.
Line: 479
static public function filter_srcset( $sources, $size_array, $image_src, $image_meta, $attachment_id ): array|false;
| Type | Name | Description |
|---|---|---|
array|false |
$sources |
Candidates. |
array |
$size_array |
Requested size. |
string |
$image_src |
Image URL. |
array |
$image_meta |
Metadata. |
int |
$attachment_id |
Attachment ID. |
Returns: array|false — Candidates.
image_editors() static
Substitute core editors that read backups but keep output in uploads.
Line: 504
static public function image_editors( array $editors ): array;
| Type | Name | Description |
|---|---|---|
array |
$editors |
Editor classes. |
Returns: array — Editor classes.
editor_source() static
Resolve a verified main-file backup for core image editing.
Line: 523
static public function editor_source( string $path ): string;
| Type | Name | Description |
|---|---|---|
string |
$path |
Served file. |
Returns: string — Input path.
delete_backups() static
Remove backups when their attachment is intentionally deleted.
Line: 546
static public function delete_backups( int $id ): void;
| Type | Name | Description |
|---|---|---|
int |
$id |
Attachment ID. |
Returns: void
release_delete_lock() static
Release the deletion lock and remove its file once core has deleted the attachment.
Line: 568
static public function release_delete_lock( $id ): void;
| Type | Name | Description |
|---|---|---|
int |
$id |
Attachment ID. |
Returns: void
prepare_delete() static
Prevent deletion from discarding recovery data during another operation.
Line: 586
static public function prepare_delete( $delete, $post ): mixed;
| Type | Name | Description |
|---|---|---|
mixed |
$delete |
Prior filter decision. |
\WP_Post |
$post |
Attachment. |
Returns: mixed — Prior decision, or false while busy.