Coder Social home page Coder Social logo

lireincoreimgcachebundle's Introduction

Image effect, thumb and cache bundle for Symfony

Build Status Latest Stable Version Total Downloads License

About

The lireincore/imgcache integration for Symfony framework.

Install

Add the "lireincore/imgcache-bundle": "^0.4" package to your require section in the composer.json file

or

$ php composer.phar require lireincore/imgcache-bundle

Usage

To use this bundle, you need to create the lireincore_imgcache.yaml file in your config/packages folder and paste this boilerplate:

# config/packages/lireincore_imgcache.yaml

lireincore_imgcache:
    srcdir: '%kernel.project_dir%/files'
    destdir: '%kernel.project_dir%/public/thumbs'
    webdir: '%kernel.project_dir%/public'
    presets:
        origin:
            effects:
                - { type: 'resize', params: { width: '50%', height: 100 } }
                - 'grayscale'

Add listener class and configure for event handling when thumb created (required symfony/event-dispatcher: ^4.3 or another psr-14 compatible dispatcher):

# config/services.yaml

services:
    Psr\EventDispatcher\EventDispatcherInterface: '@event_dispatcher'
    App\Event\ThumbCreatedListener:
        tags:
            - { name: kernel.event_listener, event: LireinCore\ImgCache\Event\ThumbCreatedEvent, method: onThumbCreated }

See lireincore/imgcache README.md for more information about the available effects and other config options.

Use in your code:

$imgcache = $this->container->get('lireincore_imgcache.service.imgcache');
// get thumb url for image '{srcdir}/blog/image.jpg' (preset 'origin')
$url = $imgcache->url('blog/image.jpg', 'origin');

See lireincore/imgcache README.md for more information about the available functions.

License

This project is licensed under the MIT License - see the License File file for details

lireincoreimgcachebundle's People

Contributors

lireincore 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.