microstudi/silex-image-controller

Microstudi/Image Controller Service Provider for Silex.

v2.0.2 2017-05-02 11:10 UTC

This package is not auto-updated.

Last update: 2024-05-10 14:05:00 UTC


README

A auto-image resize controller using Intervention/image service provider for Silex

Downloads Travis status License

Requirements

Install

Using composer:

composer require microstudi/silex-image-controller

Usage

use Microstudi\Silex\ImageController\ImageController;
use Microstudi\Silex\InterventionImage\InterventionImageServiceProvider;

$app = new Silex\Application();
$app->register(new InterventionImageServiceProvider);
      ;

//Automatic images
$app->mount('/your_path', new ImageController(array(
                'image_path' => '/path/to/original/images',
                'image_cache_path' => '/path/to/cache/folder'
            ) ));

$app->run();

Twig Helper: If twig is present a convenient function can be used to generate proper urls for auto-resized images image_path(image, size):

{{ image_path('path/to/image.png', 100, 100) }}
{{ image_path('path/to/image.png', 100, 100, 'c') }}

URLs examples:

your_path/200x300/products/image_product.jpg    <- width or height will be
                                                   changed if necessary but
                                                   never increased
your_path/200x300xc/products/image_product.jpg  <- cropped, ensures exact sizes
your_path/200x0/products/image_product.jpg      <- auto-calculate height
your_path/0x300/products/image_product.jpg      <- auto-calculate width

Options

  • intervention.image - Instance of Intervention\Image\ImageManager.
  • intervention.response - For use ImageManager directly such as $app['intervention.response']($image)
  • intervention.driver - Driver used (imagick or gd)

Tests

$ composer install
$ vendor/bin/phpunit

Changelog

2.0.2

  • README example fix.

2.0.0

  • Updated for Silex 2.0

1.0.1

  • Readme fix
  • Locked Silex to version 1.1

1.0.0

  • First release

LICENSE

The MIT LICENSE (MIT)