studiow / placeholder
Placeholder images via placeholder.com
v0.0.1
2018-08-10 10:43 UTC
Requires
- php: >=7.1
Requires (Dev)
- phpunit/phpunit: ^7.3
This package is auto-updated.
Last update: 2024-12-24 21:15:26 UTC
README
Placeholder images via placeholder.com
Installation
The (highly) recommended way to install studiow/placeholder is by using Composer
composer require studiow/placeholder
Example usage
$image = new Studiow\Placeholder\Image(300, 250); echo (string) $image; //will write 'https://via.placeholder.com/300x250
Options
We can set different options for our placeholder image. Please note that Image objects are immutable!
The following options are available:
Dimensions
You can change the width and height
$resized = $image->width($new_width)->height($new_height);
File format
Sets the file format that will be returned. Can be any of 'gif', 'jpg', 'jpeg' or 'png'
$resized = $image->format('jpg');
Colors
We can change the background and foreground color. You must provide a hex color (000 to fff or 000000 to ffffff)
$white_background = $image->background('ffffff'); $black_text = $image->color('000');
Text
By default, the text in the image shows the dimensions (e.g. '300x250'). We can change that, too
$withText = $image->text('My Image Text');