10-04-2026
This commit is contained in:
parent
4d6b4930b2
commit
4bb89aad8c
836 changed files with 52961 additions and 5950 deletions
34
app/View/Components/WebPicture.php
Normal file
34
app/View/Components/WebPicture.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\View\Components;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class WebPicture extends Component
|
||||
{
|
||||
public string $webpSrc;
|
||||
|
||||
public bool $hasWebp;
|
||||
|
||||
public function __construct(
|
||||
public string $src,
|
||||
public string $alt = '',
|
||||
public string $class = '',
|
||||
public string $loading = 'lazy',
|
||||
public string $width = '',
|
||||
public string $height = '',
|
||||
) {
|
||||
$this->webpSrc = preg_replace('/\.(jpe?g|png)$/i', '.webp', $this->src);
|
||||
$this->hasWebp = file_exists(public_path(
|
||||
str_replace(asset(''), '', $this->webpSrc)
|
||||
));
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('components.web-picture');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue