2017-25 © Pedro Peláez
 

module responsiveimage

Zend Framework 2 module that responsibly scales and serves images

image

thisismn/responsiveimage

Zend Framework 2 module that responsibly scales and serves images

  • Friday, June 27, 2014
  • by peterhough
  • Repository
  • 7 Watchers
  • 2 Stars
  • 78 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Installation

Composer Installation

{
    "require": {
        "thisismn/responsiveimage": "1.*"
    }
}

Load the Module

config/application.config.php, (*1)

'modules' => array(
    'ResponsiveImage',
    'Application',
),

Configuration

Copy 'ResponsiveImage/config/responsiveimage.global.php.dist' to './config/autoload/responsiveimage.global.php'.
Copy 'ResponsiveImage/config/responsiveimage.local.php.dist' to './config/autoload/responsiveimage.local.php'., (*2)

cp vendor/thisismn/responsiveimage/config/responsiveimage.global.php.dist ./config/autoload/responsiveimage.global.php
cp vendor/thisismn/responsiveimage/config/responsiveimage.local.php.dist ./config/autoload/responsiveimage.local.php

Change any settings in these files according to your needs.
Ensure that the cache and persistence directories are writable and the resource directory exists (see the Install WURFL section)., (*3)

Recipes

Copy 'ResponsiveImage/recipes' to './recipes'., (*4)

cp -r vendor/thisismn/responsiveimage/recipes ./

Rename and change recipes according to your needs, see the Usage section., (*5)

Install WURFL

http://sourceforge.net/projects/wurfl/files/WURFL/, (*6)

Download the latest wurfl.zip, extract it and place the wurfl.xml in the directory specified by the config variable:, (*7)

'config' => array(
        'wurfl' => array(
            'wurflFile' => 'My directory'
        )
);

Example

wget http://sourceforge.net/projects/wurfl/files/WURFL/2.3.5/wurfl-2.3.5.zip/download
unzip wurfl-2.3.5.zip
cp wurfl.xml data/resource/

Usage

View

In the view call the ResponsiveRoute helper passing in the recipe name and the image source., (*8)

<img src="<?= $this->responsiveRoute('hero', '/img/bananaman.jpg'); ?>" alt="Eric Wimp">

Recipes

The JSON files in the recipes directory control how the image will appear on different devices., (*9)

Devices detection is either mobile, tablet or desktop. If detection fails a default configuration can be used., (*10)

{
    "mobile": {

    },
    "tablet": {

    },
    "desktop": {

    },
    "default": {

    }
}

Scale

Specifying width will resize the image to that width keeping the correct ratio.
Specifying height will resize the image to that height keeping the correct ratio.
If width and height are both specified the image will be scaled to the lowest value keeping the correct ratio., (*11)

"mobile": {
    "width": 200,
    "height": 300
},

Ignoring Ratio

If width and height are both specified and ratio is set to false the ratio will be ignored and the image zoom cropped from the centre to the specified size., (*12)

"mobile": {
    "width": 200,
    "height": 200,
    "ratio": false
}

Art Direction

Sometimes a different crop or zoom of the image is desirable for narrow widths., (*13)

Along with a width and height specifying the artDirection property and an x and y position will crop the image using the X and Y as a centre point.
This will be relative to the size of the original image., (*14)

Adding width and height properties in to the artDirection property allows the image to be zoomed before the crop is taken., (*15)

"mobile": {
    "width": 50,
    "height": 50,
    "artDirection": {
        "x": 202,
        "y": 109,
        "width": 400,
        "height": 300
    }
}

Quality

The quality parameter ranges from 1 - worse to 95 - best and alters the JPEG compression., (*16)

"tablet": {
    "width": 500,
    "height": 700,
    "quality": 75
}

Dependencies

  • phpThumb - https://github.com/JamesHeinrich/phpThumb
  • WURFL PHP API - https://github.com/mimmi20/Wurfl
  • WURFL - http://sourceforge.net/projects/wurfl/files/WURFL

For performance it is recommended that the following are also installed: * ImageMagick - http://www.imagemagick.org, (*17)

The Versions

27/06 2014

dev-master

9999999-dev

Zend Framework 2 module that responsibly scales and serves images

  Sources   Download

GPL-3.0

The Requires

 

27/06 2014

v1.0.0

1.0.0.0

Zend Framework 2 module that responsibly scales and serves images

  Sources   Download

GPL-3.0

The Requires