Skip to content

kakposoe/laravel-placeholder-image

Repository files navigation

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:

{{ PlaceholderImage::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:

{{ PlaceholderImage::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.

Credits

About

Simple placeholder image generator

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages