Skip to content
Corex

MediaImage

Corex\Media\MediaImage · class · Add-ons layer

The optimized-image helper (spec 048): resolves a WordPress attachment into the data the {@see PictureRenderer} needs (the source, the WebP sibling if it exists, srcset/sizes, alt) and renders the <picture>. A thin WP boundary; the markup judgement is the pure renderer. Degrades to a plain <img> when there is no WebP sibling.

pictureForUrl(string $url, string $alt, array $opts): string

Section titled “pictureForUrl(string $url, string $alt, array $opts): string”

Optimized markup for a raw image URL (spec 061): a <picture> with a WebP <source> when a sibling exists on disk, else a plain <img>. The seam CoreX UI blocks (which hold URLs, not attachment IDs) can opt into via the corex_media_optimize_image filter — no hard dependency. $opts may carry class, loading, and lcp so a block keeps its markup when it opts in.

render(int $attachmentId, string $size, bool $lcp): string

Section titled “render(int $attachmentId, string $size, bool $lcp): string”