slexx / laravel-webp
Detect webp support in laravel framework
Installs: 3 723
Dependents: 0
Suggesters: 0
Security: 0
Stars: 10
Watchers: 2
Forks: 3
Open Issues: 2
Requires
- php: >=7.0
- illuminate/support: *
This package is auto-updated.
Last update: 2024-10-29 05:22:47 UTC
README
Install
$ 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
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! */ }