Placeholder images via placeholder.com
The (highly) recommended way to install studiow/placeholder is by using Composer
composer require studiow/placeholder
$image = new Studiow\Placeholder\Image(300, 250);
echo (string) $image; //will write 'https://via.placeholder.com/300x250
We can set different options for our placeholder image. Please note that Image objects are immutable!
The following options are available:
You can change the width and height
$resized = $image->width($new_width)->height($new_height);
Sets the file format that will be returned. Can be any of 'gif', 'jpg', 'jpeg' or 'png'
$resized = $image->format('jpg');
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');
By default, the text in the image shows the dimensions (e.g. '300x250'). We can change that, too
$withText = $image->text('My Image Text');