@props([ 'src', 'alt' => '', 'widths' => [640, 960, 1280, 1920], 'sizes' => '100vw', 'priority' => false, 'class' => '', 'imgClass' => 'h-full w-full object-cover', 'width' => null, 'height' => null, ]) @php $path = ltrim($src, '/'); $ext = pathinfo($path, PATHINFO_EXTENSION) ?: 'jpg'; $base = preg_replace('/\.[^.]+$/', '', $path); $srcsetParts = []; foreach ($widths as $w) { $candidate = public_path($base.'-'.$w.'.'.$ext); if (is_file($candidate)) { $srcsetParts[] = asset($base.'-'.$w.'.'.$ext).' '.$w.'w'; } } $srcUrl = asset($path); $webp = public_path($base.'.webp'); $avif = public_path($base.'.avif'); @endphp class($class) }}> @if (is_file($avif)) @endif @if (is_file($webp)) @endif @if (count($srcsetParts)) @endif {{ $alt }}