Code Monkey home page Code Monkey logo

laravel-placeholder-image's Introduction

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

laravel-placeholder-image's People

Contributors

kakposoe avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

laravel-placeholder-image's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.