2017 © Pedro Peláez
 

symfony-bundle image-bundle

Allow to crop local and remote image before uploading them through a classic form.

image

prolix/image-bundle

Allow to crop local and remote image before uploading them through a classic form.

  • Monday, September 18, 2017
  • by kuldippujara
  • Repository
  • 2 Watchers
  • 0 Stars
  • 39 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 12 Forks
  • 0 Open issues
  • 12 Versions
  • 11 % Grown

The README.md

PrestaImageBundle

Build Status Scrutinizer Code Quality Latest Stable Version Total Downloads, (*1)

Overview

PrestaImageBundle is a Symfony bundle providing tools to resize local/remote images before uploading them through a classic form. It uses Cropper jQuery plugin., (*2)

Installation

Require the bundle as a Composer dependency

php composer.phar require presta/image-bundle

Enable the bundles in the kernel

You must add the following bundles into app/AppKernel.php:, (*3)

<?php

public function registerBundles()
{
    $bundles = [
        // ...
        new Vich\UploaderBundle\VichUploaderBundle(),
        new Presta\ImageBundle\PrestaImageBundle(),
    ];
}

Configure the bundle

You must use the image_widget.html.twig form theme into app/config.yml., (*4)

twig:
    form_themes:
        - "PrestaImageBundle:form:image_widget.html.twig"

You must include the routing into app/config/routing.yml:, (*5)

presta_image:
    resource: "@PrestaImageBundle/Resources/config/routing.yml"

See VichUploader [documentation][5] to configure the bundle., (*6)

Install assets

See Cropper quick start section to install assets., (*7)

Note that jQuery and Bootstrap are required., (*8)

Don't forget to include the following assets in your page:, (*9)

  • /path/to/cropper/dist/cropper.min.css
  • /path/to/cropper/dist/cropper.min.js
  • @PrestaImageBundle/Resources/public/css/cropper.css
  • @PrestaImageBundle/Resources/public/js/cropper.js

Usage

Initialize cropper

(function(w, $) {

    'use strict';

    $(function() {
        $('.cropper').each(function() {
            new Cropper($(this));
        });
    });

})(window, jQuery);

Use the form type

<?php

use Presta\ImageBundle\Form\Type\ImageType;

public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        ->add('image', ImageType::class)
    ;
}

Available options for the ImageType:, (*10)

  • aspect_ratio (array): a list of aspect ratio to apply when resizing an image
  • cropper_options (array): a list of options supported by cropper (default: ['autoCropArea' => 1])
  • max_width (int): the max width of the cropped image send to server (default: 320)
  • max_height (int): the max height of the cropped image send to server (default: 180)
  • preview_width (int): the max width to use when displaying the image preview (default: 320)
  • preview_height (int): the max height to use when displaying the image preview (default: 180)
  • download_uri (string): the path where the image is located (default: null, automatically set)
  • download_link (bool): whether the end user should be able to add a remote image by URL (default: true)
  • upload_mimetype (string): format of the image to be uploaded (default: image/png)
    (Note: If choosen mimetype is not supported by browser it will silently fall back to image/png)
  • upload_quality (float): quality (0..1) of uploaded image for lossy imageformats (eg. image/jpeg) (default: 0.92)

Notes

You can find Cropper options here., (*11)

The max_width and max_height options are used to define maximum size the cropped uploaded image will be. Bigger images (after cropping) are scaled down., (*12)

Security Note: NEVER rely on this size constraints and the format settings as they can be easily manipulated client side. ALWAYS validate the image-data, -size, -format at server side!, (*13)

Contributing

Pull requests are welcome., (*14)

Thanks to everyone who has contributed already., (*15)


This project is supported by PrestaConcept, (*16)

Lead Developer : @J-Ben87, (*17)

Released under the MIT License, (*18)

The Versions

18/09 2017

dev-master

9999999-dev https://github.com/prestaconcept/PrestaImageBundle

Allow to crop local and remote image before uploading them through a classic form.

  Sources   Download

MIT

The Requires

 

form symfony2 bundle image remote local picture

18/09 2017

1.8

1.8.0.0 https://github.com/prestaconcept/PrestaImageBundle

Allow to crop local and remote image before uploading them through a classic form.

  Sources   Download

MIT

The Requires

 

form symfony2 bundle image remote local picture

28/06 2017

v1.7

1.7.0.0 https://github.com/prestaconcept/PrestaImageBundle

Allow to crop local and remote image before uploading them through a classic form.

  Sources   Download

MIT

The Requires

 

form symfony2 bundle image remote local picture

26/06 2017

1.6

1.6.0.0 https://github.com/prestaconcept/PrestaImageBundle

Allow to crop local and remote image before uploading them through a classic form.

  Sources   Download

MIT

The Requires

 

form symfony2 bundle image remote local picture

22/06 2017

v1.5

1.5.0.0 https://github.com/prestaconcept/PrestaImageBundle

Allow to crop local and remote image before uploading them through a classic form.

  Sources   Download

MIT

The Requires

 

form symfony2 bundle image remote local picture

22/06 2017

dev-Fix-vichuploader-storage-injection

dev-Fix-vichuploader-storage-injection https://github.com/prestaconcept/PrestaImageBundle

Allow to crop local and remote image before uploading them through a classic form.

  Sources   Download

MIT

The Requires

 

form symfony2 bundle image remote local picture

20/06 2017

v1.4

1.4.0.0 https://github.com/prestaconcept/PrestaImageBundle

Allow to crop local and remote image before uploading them through a classic form.

  Sources   Download

MIT

The Requires

 

form symfony2 bundle image remote local picture

20/06 2017

dev-27-cropper-options

dev-27-cropper-options https://github.com/prestaconcept/PrestaImageBundle

Allow to crop local and remote image before uploading them through a classic form.

  Sources   Download

MIT

The Requires

 

form symfony2 bundle image remote local picture

06/06 2017

v1.3

1.3.0.0 https://github.com/prestaconcept/PrestaImageBundle

Allow to crop local and remote image before uploading them through a classic form.

  Sources   Download

MIT

The Requires

 

form symfony2 bundle image remote local picture

28/05 2017

v1.2

1.2.0.0 https://github.com/prestaconcept/PrestaImageBundle

Allow to crop local and remote image before uploading them through a classic form.

  Sources   Download

MIT

The Requires

 

form symfony2 bundle image remote local picture

12/05 2017

v1.1

1.1.0.0 https://github.com/prestaconcept/PrestaImageBundle

Allow to crop local and remote image before uploading them through a classic form.

  Sources   Download

MIT

The Requires

 

form symfony2 bundle image remote local picture

11/10 2016

v1.0

1.0.0.0 https://github.com/prestaconcept/PrestaImageBundle

Allow to crop local and remote image before uploading them through a classic form.

  Sources   Download

MIT

The Requires

 

form symfony2 bundle image remote local picture