2017 © Pedro Peláez
 

symfony-bundle thumbnailbundle

A Symfony2 bundle that creates Thumbnails on the fly using the GD library

image

just/thumbnailbundle

A Symfony2 bundle that creates Thumbnails on the fly using the GD library

  • Wednesday, July 25, 2018
  • by just
  • Repository
  • 1 Watchers
  • 3 Stars
  • 373 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 21 Versions
  • 3 % Grown

The README.md

Just/ThumbnailBundle - Symfony2/3/4 Bundle for on-the-fly Thumbnails Creation

Overview

This is a bundle for the Symfony2, Symfony3 and Symfony4 framework that creates Thumbnails on first demand. The thumbnails then are stored using the Symfony cache system. It creates a thumbnail of a image in the given size and stores it in cache for the next calls, until the image changes. The bundle has a new face-detection feature to avoid cut off of faces., (*1)

SensioLabsInsight, (*2)

License

This bundle is released under the MIT license, (*3)

Installation

Step1: Using Composer

Add the following line to your composer.json require block:, (*4)

// composer.json
{
    // ...
    require: {
        // ...
        "just/thumbnailbundle": "~2.0"
    }
}

Then, you can install the new dependencies by running Composer's update command from the directory where your composer.json file is located:, (*5)

$ php composer.phar update

Step 2: Register the Bundle

Modify your AppKernel with the following line:, (*6)

<?php
// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new Just\ThumbnailBundle\JustThumbnailBundle(),
    // ...
);

Step 3: Configure the bundle

``` yaml, (*7)

app/config/config.yml

just_thumbnail: imagesrootdir: "/path/to/the/images/root/dir/on/server/" placeholder: "/path/to/a/placeholder/image.jpg" expiretime: 86400, (*8)

All parameters are optional. 
The default imagesrootdir is the Symfony web-directory. 
The placeholder-Image will be showen if the original image is not readable or not found. If the placeholder parameter is not set then the Controller will return a "404 Not found" message.
"expiretime" is maximum age of a thumbnail in cache in seconds. After this time the thumbnail will be regenerated. Default value is 86400 (one day).

The thumbnail is stored in cache by a key that is generated using the image-name, the maxx-parameter, the maxy-parameter, the mode-parameter and the creationtime. If one of those parameters changes than the thumbnail will be regenerated.

If not already done, you have to define a cache service
``` yaml
# app/config/config.yml
services:
  cache:
    class: Doctrine\Common\Cache\ApcuCache

Note:, (*9)

The JustThumbnailBundle needs to have gd.jpeg_ignore_warning set to "1". Set gd.jpeg_ignore_warning to "1" in your php.ini, and restart your webserver., (*10)

Step 4: Import JustThumbnailBundle routing file

In YAML:, (*11)

``` yaml, (*12)

app/config/routing.yml

just_thumbnail_bundle: resource: "@JustThumbnailBundle/Resources/config/routing.yml", (*13)


Or if you prefer XML: ``` xml <!-- app/config/routing.xml --> <import resource="@JustThumbnailBundle/Resources/config/routing.yml"/>

Usage:

The thumbnail will be generated just in time when the url is called:, (*14)

/thumbnails/{mode}/{maxx}x{maxy}/{img}
/thumbnails/{mode}/{maxx}x/{img}
/thumbnails/{mode}/x{maxy}/{img}

Parameter "mode"

This parameter can be set to "normal", "crop", "stretch" and "max". * normal: Sets the image to the maximum height or width, without changing the width/height proportion; * crop: The image will be cropped exactly to the given height and width without changing the width/height proportion; * stretch: Sets the image to the maximum height or width, the width/height proportion changes. * max: Sets the image to the maximum height or width, without changing the width/height proportion;, (*15)

Parameter maxx and maxy

"maxx" is the maximum width and "maxy" the maximun height of the generated thumbnail., (*16)

Placeholder

You can overwrite the placeholder-file-config by adding a "placeholder"-Parameter to the url. Example: www.yourdomain.tld/thumbnails/stretch/800x225/path/to/image?placeholder=new_placeholder_image.jpg, (*17)

Parameter "center"

This parameter can be set to "", "auto", or "[int],[int]". Default is "". This parameter can be used to define a center point of a image that should be always visible in crop mode. This is to avoid that highlights of the image are cut off. If set to "auto", the script will try to detect a face in the image. If found, the center will be set to the center of the detected face. So the face should not be cut off., (*18)

Twig Helper

You can use the twig helper to generate the URL :, (*19)

{{thumbnail({'img':'path/to/image','maxx':320,'maxy':240,'mode':'stretch'})}}

will generate something like:, (*20)

/thumbnails/stretch/300x240/path/to/image

knpbundles.com, (*21)

The Versions

25/07 2018

dev-master

9999999-dev https://github.com/julianstricker/ThumbnailBundle

A Symfony2 bundle that creates Thumbnails on the fly using the GD library

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony2 bundle thumbnail

25/07 2018

2.0.19

2.0.19.0 https://github.com/julianstricker/ThumbnailBundle

A Symfony2 bundle that creates Thumbnails on the fly using the GD library

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony2 bundle thumbnail

01/03 2017

2.0.18

2.0.18.0 https://github.com/julianstricker/ThumbnailBundle

A Symfony2 bundle that creates Thumbnails on the fly using the GD library

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony2 bundle thumbnail

01/03 2017

2.0.17

2.0.17.0 https://github.com/julianstricker/ThumbnailBundle

A Symfony2 bundle that creates Thumbnails on the fly using the GD library

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony2 bundle thumbnail

23/12 2016

2.0.16

2.0.16.0 https://github.com/julianstricker/ThumbnailBundle

A Symfony2 bundle that creates Thumbnails on the fly using the GD library

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony2 bundle thumbnail

23/12 2016

2.0.15

2.0.15.0 https://github.com/julianstricker/ThumbnailBundle

A Symfony2 bundle that creates Thumbnails on the fly using the GD library

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony2 bundle thumbnail

06/10 2016

2.0.14

2.0.14.0 https://github.com/julianstricker/ThumbnailBundle

A Symfony2 bundle that creates Thumbnails on the fly using the GD library

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony2 bundle thumbnail

06/10 2016

dev-facedetection

dev-facedetection https://github.com/julianstricker/ThumbnailBundle

A Symfony2 bundle that creates Thumbnails on the fly using the GD library

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony2 bundle thumbnail

30/09 2016

2.0.13

2.0.13.0 https://github.com/julianstricker/ThumbnailBundle

A Symfony2 bundle that creates Thumbnails on the fly using the GD library

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony2 bundle thumbnail

30/09 2016

2.0.12

2.0.12.0 https://github.com/julianstricker/ThumbnailBundle

A Symfony2 bundle that creates Thumbnails on the fly using the GD library

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony2 bundle thumbnail

30/09 2016

2.0.11

2.0.11.0 https://github.com/julianstricker/ThumbnailBundle

A Symfony2 bundle that creates Thumbnails on the fly using the GD library

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony2 bundle thumbnail

21/03 2016

2.0.10

2.0.10.0 https://github.com/julianstricker/ThumbnailBundle

A Symfony2 bundle that creates Thumbnails on the fly using the GD library

  Sources   Download

MIT

The Requires

 

symfony2 bundle thumbnail

07/03 2016

2.0.9

2.0.9.0 https://github.com/julianstricker/ThumbnailBundle

A Symfony2 bundle that creates Thumbnails on the fly using the GD library

  Sources   Download

MIT

The Requires

 

symfony2 bundle thumbnail

10/02 2016

2.0.8

2.0.8.0 https://github.com/julianstricker/ThumbnailBundle

A Symfony2 bundle that creates Thumbnails on the fly using the GD library

  Sources   Download

MIT

The Requires

 

symfony2 bundle thumbnail

09/02 2016

2.0.7

2.0.7.0 https://github.com/julianstricker/ThumbnailBundle

A Symfony2 bundle that creates Thumbnails on the fly using the GD library

  Sources   Download

MIT

The Requires

 

symfony2 bundle thumbnail

11/01 2016

2.0.6

2.0.6.0 https://github.com/julianstricker/ThumbnailBundle

A Symfony2 bundle that creates Thumbnails on the fly using the GD library

  Sources   Download

MIT

The Requires

 

symfony2 bundle thumbnail

11/01 2016

2.0.5

2.0.5.0 https://github.com/julianstricker/ThumbnailBundle

A Symfony2 bundle that creates Thumbnails on the fly using the GD library

  Sources   Download

MIT

The Requires

 

symfony2 bundle thumbnail

09/06 2015

2.0.4

2.0.4.0 https://github.com/julianstricker/ThumbnailBundle

A Symfony2 bundle that creates Thumbnails on the fly using the GD library

  Sources   Download

MIT

The Requires

 

symfony2 bundle thumbnail

11/05 2015

2.0.2

2.0.2.0 https://github.com/julianstricker/ThumbnailBundle

A Symfony2 bundle that creates Thumbnails on the fly using the GD library

  Sources   Download

MIT

The Requires

 

symfony2 bundle thumbnail

11/05 2015

2.0.3

2.0.3.0 https://github.com/julianstricker/ThumbnailBundle

A Symfony2 bundle that creates Thumbnails on the fly using the GD library

  Sources   Download

MIT

The Requires

 

symfony2 bundle thumbnail

25/02 2015

2.0.1

2.0.1.0 https://github.com/julianstricker/ThumbnailBundle

A Symfony2 bundle that creates Thumbnails on the fly using the GD library

  Sources   Download

MIT

The Requires

 

symfony2 bundle thumbnail