slexx/laravel-webp

Detect webp support in laravel framework

dev-master 2018-12-29 10:24 UTC

This package is auto-updated.

Last update: 2024-03-29 03:26:18 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! */
}