slexx/laravel-webp

Detect webp support in laravel framework
4,823 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

philo/laravel-blade

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

684,122 355
fitztrev/laravel-html-minify

Minifies the HTML output of Laravel 4 applications

215,237 414
igaster/laravel-theme

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

1,263,205 515
spatie/laravel-blade-javascript

A Blade directive to export variables to JavaScript

937,970 620
riverskies/laravel-mobile-detect

Instant mobile detection access directly from within Blade templates.

1,546,972 231