jaimevalasek/jv-easy-php-thumbnail

A generic module to generate thumbnail images for ZF2. Using this module you can generate thumbnails of images and display them on the site with an option to cache or use to generate and save in a folder.

dev-master 2013-09-26 12:27 UTC

This package is not auto-updated.

Last update: 2024-06-04 03:42:23 UTC


README

Create By: Jaime Marcelo Valasek

Use this module to generate thumbnail to apply the images on your website.

This module is using the library Easy Php Thumbniail, to know how to use the methods access the author's website - http://www.mywebmymail.com/?q=content/easyphpthumbnail-class

Futures video lessons poderam be developed and posted on the website or in http://www.zf2.com.br/tutoriais Youtube channel http://www.youtube.com/zf2tutoriais

Installation

Download this module into your vendor folder.

After done the above steps, open the file config / application.config.php. And add the module with the name JVEasyPhpThumbnail.

Generating thumbnail in core and save it in the folder

  • Use this code to generate the thumbnail when you're uploading the image.
<?php

use JVEasyPhpThumbnail\Library\PHPThumb as EasyPhpThumbnail;

$phpThumb = new PHPThumb();
$phpThumb->Thumblocation = $_SERVER['DOCUMENT_ROOT'] . "/imagens/thumbs/";
$phpThumb->Chmodlevel = '0755';
$phpThumb->Thumbsaveas = 'jpg';
$phpThumb->Thumbsize = 300;
$phpThumb->Cropimage = array(2,0,40,40,50,50);

$destination = $_SERVER['DOCUMENT_ROOT'] . "/imagens/";
$nomeDoArquivo = 'minhaImagem.jpg';

$phpThumb->Createthumb($destination . '/' . $nomeDoArquivo, 'file');

Using the view helper to create thumbnails

When using the view helper will be generated and stored in the thumbnail folder Imagecache

// Controller code
$arrConfigure = array();
$arrConfigure['Thumbsize'] = 300;
$arrConfigure['Quality'] = 55;
$arrConfigure['Cropimage'] = array(2,0,40,40,50,50);

return new ViewModel(array(
    'arrConfigure' => $arrConfigure
));

// View Code
<img alt="nomedaimagem" src="<?php echo $this->phpthumb()->setImage('/conteudos/thumbs/', $nomedaimagem, $arrConfigure);?>">