2017 © Pedro Peláez
 

library nette-webimages

On-the-fly generated web images for your Nette app

image

the-sound-of-tnt/nette-webimages

On-the-fly generated web images for your Nette app

  • Tuesday, March 27, 2018
  • by TheSoundOfTNT
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 18 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

Requirements

Installation

1) Copy source codes from Github or using Composer:, (*1)

$ composer require dotblue/nette-webimages

2) Register as Configurator's extension:, (*2)

extensions:
    webimages: DotBlue\WebImages\Extension

Concept

This addon gives you power to automatically generate different sized versions of images throughout your app. When browser will request new version of image, application will generate it and save it to its requested destination, so that in next HTTP request, your server will just serve existing file., (*3)

To enable this, modify your .htaccess:, (*4)

# front controller
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(pdf|js|ico|gif|css|rar|zip|tar\.gz)$ index.php [L]

Usage

First, you have to define your DotBlue\WebImages\IProvider implementation. Its responsibility is to generate new version of image using Nette\Image. Check examples for inspiration - the only required method getImage should return Nette\Image instance of queried image., (*5)

When you have it, register it in configuration:, (*6)

webimages:
    providers:
        - <name of your class>

Secondly you have to specify route where your images will be available. Central point of the route is id parameter, which should uniquely identify your image. Lets setup simple route:, (*7)

webimages:
    routes:
        - images/<id>-<width>x<height>.jpg

By default all these routes will be prepended before your other routes - assuming you use Nette\Application\Routers\RouteList as your root router. You can disable this by setting prependRoutesToRouter: false. Then it's your responsibility to plug webimages router (service webimages.router) to your routing implementation., (*8)

Addon gives you new macro n:src. Now you're ready to use it., (*9)

<img n:src="foo, 200, 150">

This will result in following HTML:, (*10)

<img src="/images/foo-200x150.jpg">

Creation of this file will handle your implementation of DotBlue\WebImages\IProvider., (*11)

HTTPS

To toggle secured route flag use following syntax in your configuration:, (*12)

webimages:
    routes:
        - mask: images/<id>-<width>x<height>.jpg
          secured: true

The Versions

27/03 2018

dev-master

9999999-dev

On-the-fly generated web images for your Nette app

  Sources   Download

BSD-3-Clause

The Requires

 

routing nette images

11/01 2016

dev-devel

dev-devel

On-the-fly generated web images for your Nette app

  Sources   Download

BSD-3-Clause

The Requires

 

routing nette images

26/02 2015

2.0.0

2.0.0.0

On-the-fly generated web images for your Nette app

  Sources   Download

BSD-3-Clause

The Requires

 

routing nette images

18/09 2014

dev-tests

dev-tests

On-the-fly generated web images for your Nette app

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

routing nette images

14/05 2014

1.0.2

1.0.2.0

On-the-fly generated web images for your Nette app

  Sources   Download

BSD-3-Clause

The Requires

 

routing nette images

11/05 2014

1.0.1

1.0.1.0

On-the-fly generated web images for your Nette app

  Sources   Download

BSD-3-Clause

The Requires

 

routing nette images

11/05 2014

1.0.0

1.0.0.0

On-the-fly generated web images for your Nette app

  Sources   Download

BSD-3-Clause

The Requires

 

routing nette images

06/05 2014

0.9.0

0.9.0.0

On-the-fly generated web images for your Nette app

  Sources   Download

BSD-3-Clause

The Requires

 

routing nette images