kreyu/placeholder-image

Generate links for placeholder images using various providers

v1.0.1 2019-04-24 17:33 UTC

This package is auto-updated.

Last update: 2024-03-25 06:26:11 UTC


README

Latest Stable Version Build Status

This package helps with usage of various placeholder image providers.
Zero dependencies, simple links.

Installation

You can install the package via composer:

composer require kreyu/placeholder-image

Testing

composer test

Usage

To generate the url placeholder image:

PlaceholderImage::with($providerAlias)->generate($width, $height, array $options, $ssl = true); 

Example usage:

PlaceholderImage::with('dummy_image')->generate(600, 400, [
    'text' => 'Beep Boop',
    'format' => 'png',
    'background' => 'FF9900',
    'foreground' => 'FFFFFF',
]);

Will give us the following url:

https://dummyimage.com/600x400/FF9900/FFFFFF.png&text=Beep+boop

Fourth argument allows to disable SSL support.

Supported providers

Using the invalid provider alias throws the InvalidProviderException

Fatal error: Uncaught Kreyu\PlaceholderImage\Exception\InvalidProviderException: 
Requested provider invalid-prov does not exist.

License

The MIT License (MIT). Please see license file for more information.