2017 © Pedro Peláez
 

symfony-bundle image-server-bundle

A very specific Image Server written for Symfony

image

audience-hero/image-server-bundle

A very specific Image Server written for Symfony

  • Wednesday, September 13, 2017
  • by futurecat
  • Repository
  • 1 Watchers
  • 1 Stars
  • 41 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 141 % Grown

The README.md

AudienceHero/ImageServerBundle

A very simple and composable image server for Symfony applications., (*1)

SensioLabsInsight Build Status Coverage Status, (*2)

Installation

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:, (*3)

$ composer require audience-hero/image-server-bundle "~1"

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation., (*4)

Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the app/AppKernel.php file of your project:, (*5)

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new AudienceHero\Bundle\ImageServerBundle\AudienceHeroImageServerBundle(),
        );

        // ...
    }

    // ...
}

Step 3: Configuration

Add this to your app/config/config.yml file:, (*6)

# ...
audience_hero_image_server:
    # (Optional) The doctrine cache provider key (See DoctrineCacheBundle documentation)
    # cache: image_server  
# ...

Step 4: Routing

Add this to your app/config/routing.yml file:, (*7)

_audience_hero_image_server:
    resource: "@AudienceHeroImageServerBundle/Resources/config/routing.yml"
    prefix:   /img
# ...

Usage

The image server responds to an endpoint and serves images with the possibility to transform them (ie: scale/crop)., (*8)

Generating URLs

In Twig templates

{{ img('http://www.example.com/image.jpg', {'size': 400x400, 'crop': 'square-center'}) }}

Anywhere else

$this->generateUrl('audience_hero_img_show', [
    'url' => 'http://www.example.com/image.jpg',
    'size' => '400x400',
    'crop' => 'square-center'
]);

Transformers

CropTransformer

Possibles values for the crop parameter:, (*9)

  • none Do not crop image
  • square Crop the image to a square
  • square-center Crop the image to a square, but centered

ResizeTransformer

Possibles values for the size parameter:, (*10)

  • 640x480 Resize the image to 640x480
  • 640x0 Resize the image to a width of 640 pixels. Height is automatically adjusted to preserve the original aspect ratio.
  • 0x480 Resize the image to a height of 480 pixels. Width is automatically adjusted to preserve the original aspect ratio.

License

See the LICENSE file., (*11)

The Versions