Skip to content
Simple placeholder image generator
PHP
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
src
tests
.editorconfig
.gitattributes
.gitignore
.styleci.yml
.travis.yml
LICENSE
README.md
composer.json
phpunit.xml

README.md

Laravel Placeholder Image

Build Status StyleCI

A convenient laravel facade which returns a placeholder image url.

Installation

Install via composer

composer require kakposoe/laravel-placeholder-image

Register Service Provider

If you use laravel < 5.5, Add service provider to config/app.php in providers section

Kakposoe\LaravelViewGenerator\LaravelViewGeneratorServiceProvider::class,

Register Facade

If you use laravel < 5.5, register package facade in config/app.php in aliases section

Kakposoe\LaravelPlaceholderImage\Facades\LaravelPlaceholderImage::class,

Publish Configuration File

php artisan vendor:publish --provider="Kakposoe\LaravelPlaceholderImage\ServiceProvider" --tag="config"

How to use

You can get a placeholder image url within your blade templates by adding:

{{ Placeholder::get($width = null, $height = null) }}

By default, images will be returned as a 600px x 400px image.

To change the dimensions of the image, simply add the $width and $height like so:

{{ Placeholder::get(300, 300) }}

Other image types

There are several different types of image at your disposal:

Profile Image

To get a profile image placeholder:

<img src="{{ PlaceholderImage::profile($width = null, $height = null) }}">

Icon image

You are able to create a placeholder image with a font-awesome icon in the middle:

<img src="{{ PlaceholderImage::icon('arrow-up') }}">

Note: By default, the fa-image icon will be returned.

Blurry image

To return a blurry image:

<img src="{{ PlaceholderImage::blur($width = null, $height = null) }}">

Keyword search

You can return a placeholder url based on a keyword:

<img src="{{ PlaceholderImage::keyword('food') }}">

Placeholder with image dimensions

An placeholder image url which has the image dimensions can be returned using the ::dimensions() method:

<img src="{{ PlaceholderImage::dimensions($width = null, $height = null) }}">

A note about production environments

As these are placeholder images, it is assumed that these should not to be used within production environments.

All placeholder images used in production will be replaced with an ::icon() placeholder image, avoiding showing inappropriate images and the impression that the image could not be found.

You can’t perform that action at this time.