Scanner
Finds convertible attachments via direct queries to avoid loading post objects.
Namespace: WebberZone\Image_Optimizer
Since: 1.0.0
Source: includes/class-scanner.php line 21
Methods
count_candidates() static
Count the attachments the plugin could convert.
Since: 1.0.0
Line: 62
static public function count_candidates( ): int;
Returns: int — Attachment count.
count_optimized() static
Count the attachments that already carry a conversion record.
Since: 1.0.0
Line: 95
static public function count_optimized( ): int;
Returns: int — Attachment count.
get_byte_totals() static
Sum the source bytes and bytes saved across every conversion record.
Since: 1.1.2
Line: 125
static public function get_byte_totals( ): array;
Returns: array — int, saved: int, formats: array<string, int>, copies: int} Byte totals.
backfill_byte_totals() static
Write byte totals for records stored before they were tracked.
Since: 1.1.2
Line: 188
static public function backfill_byte_totals( int $time_limit = ... ): bool;
| Type | Name | Description |
|---|---|---|
int |
$time_limit |
Seconds to spend before deferring the rest to a later call. |
Returns: bool — True when no record is left without totals.
flush_counts() static
Discard the cached library-wide counts.
Since: 1.0.2
Line: 229
static public function flush_counts( ): void;
Returns: void
requeue_png_skips() static
Queue PNG attachments holding a skipped copy the lossy fallback may now rescue.
Their queue rows are already done, so a normal scan would never revisit them.
Since: 1.1.1
Line: 244
static public function requeue_png_skips( ): int;
Returns: int — Number of attachments queued.
requeue_unsupported_skips() static
Queue attachments holding copies skipped for want of an encoder that now exists.
Since: 1.1.2
Line: 285
static public function requeue_unsupported_skips( ): int;
Returns: int — Number of attachments queued.
requeue_retryable() static
Clear skipped and failed results and queue those attachments for another attempt.
Since: 1.1.2
Line: 328
static public function requeue_retryable( ): int;
Returns: int — Number of attachments queued.
get_candidate_ids() static
Get a page of attachment IDs that could be converted.
Since: 1.0.0
Line: 368
static public function get_candidate_ids( int $limit = ..., int $after_id = ..., bool $only_unhandled = ... ): array;
| Type | Name | Description |
|---|---|---|
int |
$limit |
Maximum IDs to return. |
int |
$after_id |
Only return IDs greater than this. |
bool |
$only_unhandled |
Whether to skip attachments that already have a record. |
Returns: array — int> Attachment IDs, ascending.
get_outdated_ids() static
Get a page of attachment IDs holding copies made with older settings.
Since: 1.2.0
Line: 416
static public function get_outdated_ids( int $limit = ..., int $after_id = ..., array $overrides = ... ): array;
| Type | Name | Description |
|---|---|---|
int |
$limit |
Maximum IDs to return. |
int |
$after_id |
Only return IDs greater than this. |
array |
$overrides |
Conversion argument overrides. |
Returns: array — array<int, int>, last: int, exhausted: bool} Matching IDs, the last ID examined and whether the library ran out.
enqueue_all() static
Fill the queue with every attachment that still needs work.
Since: 1.0.0
Line: 470
static public function enqueue_all( bool $force = ..., bool $outdated = ... ): int;
| Type | Name | Description |
|---|---|---|
bool |
$force |
Whether to include attachments that already have a record. |
bool |
$outdated |
Whether to queue only attachments made with older settings. |
Returns: int — Number of attachments queued.
enqueue_batch() static
Queue one time-bounded page of attachments that still need work.
Since: 1.0.2
Line: 487
static public function enqueue_batch( int $after_id = ..., bool $force = ..., ?float $deadline = ..., bool $outdated = ... ): array;
| Type | Name | Description |
|---|---|---|
int |
$after_id |
Cursor; only attachments above this ID are considered. |
bool |
$force |
Whether to include attachments that already have a record. |
float|null |
$deadline |
Wall-clock deadline, or null for the default budget. |
bool |
$outdated |
Whether to queue only attachments made with older settings. |
Returns: array — int, after_id: int, done: bool} Pass result.