-.jpg * $sizes string (optional, default '100vw') * $eager bool (optional) — above the fold: eager + fetchpriority high * $class string (optional) */ $sizes = $sizes ?? '100vw'; $eager = $eager ?? false; $class = $class ?? ''; $widths = $image['widths']; $largest = max($widths); $srcset = implode(', ', array_map( static fn (int $w): string => asset("{$image['base']}-{$w}.jpg") . " {$w}w", $widths )); // Maße der größten Variante für width/height (CLS-Vermeidung). [$w, $h] = (function () use ($image, $largest): array { static $dims = []; $file = PUBLIC_PATH . "/assets/{$image['base']}-{$largest}.jpg"; $key = $file; if (!isset($dims[$key])) { $size = is_file($file) ? (getimagesize($file) ?: [0, 0]) : [0, 0]; $dims[$key] = [$size[0], $size[1]]; } return $dims[$key]; })(); ?> src="" srcset="" sizes="" alt="" width="" height="" >