@props([
'src',
'alt' => '',
'class' => '',
'loading' => null,
'fetchpriority' => null,
'width' => null,
'height' => null,
])
@php
$webpSrc = preg_replace('/\.(png|jpe?g)$/i', '.webp', $src);
$webpPath = public_path(ltrim(parse_url($webpSrc, PHP_URL_PATH) ?: $webpSrc, '/'));
$hasWebp = is_file($webpPath);
@endphp
@if($hasWebp)
except(['src', 'alt', 'class', 'loading', 'fetchpriority', 'width', 'height']) }}
>
@else
except(['src', 'alt', 'class', 'loading', 'fetchpriority', 'width', 'height']) }}
>
@endif