Recent

Rewriterclass

Rewriter

Uses <picture> so browser format selection remains safe behind caches.

Namespace: WebberZone\Image_Optimizer\Frontend
Since: 1.0.0
Source: includes/frontend/class-rewriter.php line 25

Methods

__construct()

Constructor.

Since: 1.0.0
Line: 40

public function __construct(  );

register_output_hooks()

Attach the rewriting filters, once it is clear this is a page we serve.

Since: 1.0.0
Line: 52

public function register_output_hooks(  ): void;

Returns: void

has_template_enhancement_buffer() static

Whether core provides the template enhancement output buffer.

Since: 1.0.0
Line: 77

static public function has_template_enhancement_buffer(  ): bool;

Returns: bool — True on WordPress 6.9 and later.

is_enabled()

Whether images should be rewritten for this request.

Existing sidecars remain valid even if their encoder is unavailable.

Since: 1.0.0
Line: 90

public function is_enabled(  ): bool;

Returns: bool — True when rewriting is on.

filter_content_img_tag()

Rewrite an image embedded in post content.

Since: 1.0.0
Line: 121

public function filter_content_img_tag( $filtered_image, $context, $attachment_id ): string;
Type Name Description
string $filtered_image The <img> markup.
string $context Filter context.
int $attachment_id Attachment ID, or 0 when it could not be determined.

Returns: string — Markup.

filter_attachment_image()

Rewrite an image rendered through wp_get_attachment_image().

Since: 1.0.0
Line: 136

public function filter_attachment_image( $html, $attachment_id ): string;
Type Name Description
string $html The <img> markup.
int $attachment_id Attachment ID.

Returns: string — Markup.

filter_buffer()

Rewrite buffered images outside existing <picture> elements.

Since: 1.0.0
Line: 148

public function filter_buffer( string $html ): string;
Type Name Description
string $html Page markup.

Returns: string — Markup.

wrap()

Wrap a single <img> tag in a <picture> element.

Since: 1.0.0
Line: 195

public function wrap( string $html, int $attachment_id ): string;
Type Name Description
string $html The <img> markup.
int $attachment_id Attachment ID, or 0 when unknown.

Returns: string — Markup, unchanged when no format applies.

parse_srcset() static

Split a srcset attribute into URL and descriptor pairs.

Since: 1.0.0
Line: 282

static public function parse_srcset( string $srcset ): array;
Type Name Description
string $srcset Attribute value.

Returns: array — array{0: string, 1: string}> Candidates.

flush_lazy_queue()

Write the lazily noted attachments to the queue after the page is sent.

Since: 1.0.0
Line: 334

public function flush_lazy_queue(  ): void;

Returns: void