This package provides a simple way to use Picsum.photos in your Laravel app.
You can install the package via composer:
composer require tvdr/picsum-placeholder
In order to edit the default configuration you may execute:
php artisan vendor:publish --provider="Tvdr\PicsumPlaceholder\PicsumPlaceholderServiceProvider" --tag="config"
After that, config/picsum-placeholder.php
will be created.
The configuration options are:
name | description | type | default value |
---|---|---|---|
api_url |
the base url for picsum.photos | string | https://picsum.photos/ |
width |
width of image | integer | 300 |
height |
height of image | integer | 300 |
blur |
amount of blur on image | false | integer[1..10] | false |
grayscale |
always get a grayscale image | false | true | false |
random |
append a random string to the url to bust browser cache | false | true | true |
override_route |
route to override (e.g to always load a placeholder on non existent storage images) | false | string | /storage/{path?} |
You can use the facade to write well-readable code as well as a predefined global helper method if you don't want it as a singleton
//return image url with default parameters
PicsumPlaceholder::getUrl()
picsum_placeholder()->getUrl()
//return image as a blob string with default parameters
PicsumPlaceholder::getBlob()
picsum_placeholder()->getBlob()
PicsumPlaceholder::width(250);
picsum_placeholder()->width(410);
PicsumPlaceholder::height(120);
picsum_placeholder()->height(540);
PicsumPlaceholder::blur(3);
picsum_placeholder()->blur(false);
PicsumPlaceholder::grayscale(true);
picsum_placeholder()->grayscale(false);
PicsumPlaceholder::random(true);
picsum_placeholder()->grayscale(false);
All methods are chainable so nothing stops you from using
PicsumPlaceholder::width(120)->height(500)->grayscale(false)->blur(2)->getUrl();
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email tiborbarta87@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package was generated using the Laravel Package Boilerplate.