otisz/laravel-imgix

Maintainers

Details

github.com/Otisz/Laravel-Imgix

Installs: 19 426

Dependents: 0

Suggesters: 0

Security: 0

Stars: 15

Watchers: 2

Forks: 4

v3.2.0 2020-09-04 08:53 UTC

This package is auto-updated.

Last update: 2024-11-07 20:52:34 UTC


README

Latest Stable Version Build Status Total downloads Licence

Laravel package for generating Imgix URLs for your images.

Dependencies

Install

You can install the package via Composer

$ composer require otisz/laravel-imgix

In Laravel 5.5 or above the service provider will automatically get registered. In older versions of the framework just add the service provider in config/app.php file:

'providers' => [
    ...
    Otisz\Imgix\ImgixServiceProvider::class,
    ...
],

'aliases' => [
    ...
    'Imgix' =>  Otisz\Imgix\Facades\Imgix::class,
    ...
],

You can publish the config file with:

$ php artisan vendor:publish --provider="Otisz\Imgix\ImgixServiceProvider" --tag=config

When published, the config/imgix.php config file contains:

<?php

return [
    /*
    |--------------------------------------------------------------------------
    | ImgIX Domains
    |--------------------------------------------------------------------------
    |
    | Domain sharding enables you to spread image requests across
    | multiple domains. This allows you to bypass the requests-per-host
    | limits of browsers. We recommend 2-3 domain shards maximum if you are
    | going to use domain sharding.
    |
    | @link https://github.com/imgix/imgix-php#domain-sharded-urls
    |
    */
    'domain' => env('IMGIX_DOMAIN', 'example.imgix.net'),

    /*
    |--------------------------------------------------------------------------
    | ImgIX HTTPS
    |--------------------------------------------------------------------------
    |
    | For HTTPS support.
    |
    */
    'useHttps' => env('IMGIX_HTTPS', false),

    /*
    |--------------------------------------------------------------------------
    | ImgIX Signed URLs
    |--------------------------------------------------------------------------
    |
    | To produce a signed URL, you must enable secure URLs on your source
    | and then provide your signature key to the URL builder.
    |
    | @link https://github.com/imgix/imgix-php#signed-urls
    |
    */
    'signKey' => env('IMGIX_SIGNKEY', ''),

    /*
    |--------------------------------------------------------------------------
    | ImgIX Library Param
    |--------------------------------------------------------------------------
    |
    | For security and diagnostic purposes, we default to signing all requests
    | with the language and version of library used to generate the URL.
    |
    */
    'includeLibraryParam' => env('IMGIX_LIBRARY', true),
];

Usage

Read more about srcset.

$path: The path of the image
$params: The parameters provided by Imgix

Facade

\Imgix::createUrl('bridge.png', ['w' => 100, 'h' => 100]);

\Imgix::createSrcSet('bridge.png', ['w' => 100, 'h' => 100]);

Helper

imgix('bridge.png', ['w' => 100, 'h' => 100])

imgixSrcSet('bridge.png', ['w' => 100, 'h' => 100])

Testing

$ composer test

Contributing

Security Vulnerabilities

If you discover any security-related issues, please email leventeotta@gmail.com instead of using the issue tracker. All security vulnerabilities will be promptly addressed.

Licence

The Laravel Imgix package is open-source software licensed under the MIT license.