slexx/laravel-webp

Detect webp support in laravel framework
4,844 10
Install
composer require slexx/laravel-webp
PHP:>=7.0
License:MIT
Last Updated:Jun 11, 2019
Links: GitHub  ·  Packagist
Maintainer: slexx

laravel-webp

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="https://raw.githubusercontent.com/slexx1234/laravel-webp/HEAD/image.webp"/>
@else
    <img src="https://raw.githubusercontent.com/slexx1234/laravel-webp/HEAD/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! */
}

Related Packages

tumutech/laravel-qr-code

Generate branded, scan-safe QR codes in Laravel with center logos, style templat...

7 0
philo/laravel-blade

Use the simple and yet powerful Laravel Blade templating engine as a standalone...

687,029 354
igaster/laravel-theme

Laravel Themes: Asset & Views folder per theme. Theme inheritance. Blade integra...

1,279,271 515
jeroennoten/laravel-adminlte

Easy AdminLTE v4 integration with Laravel

5,332,381 4,000
spatie/laravel-blade-javascript

A Blade directive to export variables to JavaScript

962,162 619