Downloads
Stars
Version
$ composer require slexx/laravel-webp
In Laravel 5.5 the service provider will automatically get registered. In older versions of the framework just add the service provider in config/app.php file:
'providers' => [
// ...
Slexx\LaravelWebp\LaravelWebpServiceProvider::class,
];
Add @webpJS
directive to the <head>
tag
<head>
@webpJS
<!-- ... -->
</head>
Usage in blade
@webp
<img src="/image.webp"/>
@else
<img src="/image.png"/>
@endwebp
or in js, php
if (supportsWebp()) {
// Does support!
} else {
// Does not support!
}
or in css
html.webp {
/* Does support! */
}
html.no-webp {
/* Does not support! */
}