GithubHelp home page GithubHelp logo

jeffersonsimaogoncalves / picsum-placeholder Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tvdr/picsum-placeholder

0.0 0.0 0.0 36 KB

🖼️ Use Picsum.photos in your laravel app

License: MIT License

PHP 100.00%

picsum-placeholder's Introduction

🖼️ Use Picsum.photos in your laravel app

Latest Version on Packagist Total Downloads

This package provides a simple way to use Picsum.photos in your Laravel app.

Installation

You can install the package via composer:

composer require tvdr/picsum-placeholder

Config Files

In order to edit the default configuration you may execute:

php artisan vendor:publish --provider="Tvdr\PicsumPlaceholder\PicsumPlaceholderServiceProvider" --tag="config"

After that, config/picsum-placeholder.php will be created.

The configuration options are:

name description type default value
api_url the base url for picsum.photos string https://picsum.photos/
width width of image integer 300
height height of image integer 300
blur amount of blur on image false | integer[1..10] false
grayscale always get a grayscale image false | true false
random append a random string to the url to bust browser cache false | true true
override_route route to override (e.g to always load a placeholder on non existent storage images) false | string /storage/{path?}

Usage

You can use the facade to write well-readable code as well as a predefined global helper method if you don't want it as a singleton

//return image url with default parameters
PicsumPlaceholder::getUrl()
picsum_placeholder()->getUrl()
//return image as a blob string  with default parameters
PicsumPlaceholder::getBlob()
picsum_placeholder()->getBlob()

Use the methods below to set options

Width

PicsumPlaceholder::width(250);
picsum_placeholder()->width(410);

Height

PicsumPlaceholder::height(120);
picsum_placeholder()->height(540);

Blur

PicsumPlaceholder::blur(3);
picsum_placeholder()->blur(false);

Grayscale

PicsumPlaceholder::grayscale(true);
picsum_placeholder()->grayscale(false);

Random

PicsumPlaceholder::random(true);
picsum_placeholder()->grayscale(false);

All methods are chainable so nothing stops you from using

PicsumPlaceholder::width(120)->height(500)->grayscale(false)->blur(2)->getUrl();

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.


Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.

picsum-placeholder's People

Contributors

tvdr avatar

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.