2017 © Pedro Peláez
 

symfony-bundle image-bundle

Easier image upload form bundle with Doctrine

image

arkounay/image-bundle

Easier image upload form bundle with Doctrine

  • Wednesday, July 26, 2017
  • by Arkounay
  • Repository
  • 2 Watchers
  • 2 Stars
  • 218 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 10 Versions
  • 12 % Grown

The README.md

Not maintained. Use artgris/FileManagerBundle with artgris/MediaBundle instead.

Arkounay Image Bundle - Symfony Easier Doctrine image management

alt tag, (*1)

Getting Started

  • Download the files:, (*2)

    composer require arkounay/image-bundle
  • In AppKernel.php add the bundle:, (*3)

    new Arkounay\ImageBundle\ArkounayImageBundle()
  • Then, run the following command:, (*4)

    php bin/console assets:install 
  • In your twig template, you will then need to import the required assets:, (*5)

    • CSS:, (*6)

      <link rel="stylesheet" href="{{ asset('bundles/arkounayimage/arkounay_image_bundle.css') }}">
    • JS (requires jQuery, ninsuo/symfony-collection and optionally bootstrap, Font Awesome and jQuery UI):, (*7)

      {# Import jQuery: #}
      <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
      
      {# Then the default bundle's JavaScript: #}
      {% include '@ArkounayImage/assets/include_js.html.twig' %}
  • In routing.yml, you will need to import the Ajax route:, (*8)

     arkounay_image:
         resource: "@ArkounayImageBundle/Resources/config/routing.yml"
  • In config.yml, add the following Doctrine types:, (*9)

    doctrine:
        dbal:
            types:
                json_image: Arkounay\ImageBundle\Type\JsonImageType
                json_images: Arkounay\ImageBundle\Type\JsonImagesType

Usage

In an entity, you can now add the new json_image types:, (*10)

/**
 * @var Image
 * @ORM\Column(type="json_image")
 */
private $image;

/**
 * @var ArrayCollection|Image[]
 * @ORM\Column(type="json_images")
 */
private $imageCollection;

public function __construct()
{
    $this->imageCollection = new ArrayCollection();
}

You can bound these fields to a form using its corresponding type:, (*11)

use Arkounay\ImageBundle\Form\JsonImagesType;
use Arkounay\ImageBundle\Form\JsonImageType;

// ... 

$builder
    ->add('image', JsonImageType::class)
    ->add('imageCollection', JsonImagesType::class);

Options:

JsonImageType: - 'allow_alt' => true allows the user to specify an alt - 'path_readonly' => false prevents the user from manually changing the path (it only adds a "readonly" attribute to the corresponding HTML input), (*12)

JsonsImageType:, (*13)

Some ninsuo/symfony-collection's options are available directly: - 'min' => 0 - 'max' => 100 - 'init_with_n_elements' => 1 - 'add_at_the_end' => true, (*14)

About the form HTML theme

Include bootstrap's theme, (*15)

{% form_theme form ':admin/includes:bootstrap_3_layout.html.twig' %}

To override the widget theme, check Resources/views/forms/fields.html.twig., (*16)

Other

  • By default, only ROLE_ADMIN can upload images. You can specify roles in config.yml, ie:, (*17)

    arkounay_image:
        roles: ['ROLE_SUPER_ADMIN']
  • This bundle works with EasyAdminBundle, you can for example add multiple images by specifying the proper type:, (*18)

    { property: 'imageCollection', type: 'Arkounay\ImageBundle\Form\JsonImagesType', type_options: {allow_add: true} }

The Versions

26/07 2017

dev-master

9999999-dev https://github.com/Arkounay/ImageBundle

Easier image upload form bundle with Doctrine

  Sources   Download

The Requires

 

by Antonin M

form bundle doctrine symfony image

30/01 2017

2.1.1

2.1.1.0 https://github.com/Arkounay/ImageBundle

Easier image upload form bundle with Doctrine

  Sources   Download

The Requires

 

by Antonin M

form bundle doctrine symfony image

25/01 2017

2.1.0

2.1.0.0 https://github.com/Arkounay/ImageBundle

Easier image upload form bundle with Doctrine

  Sources   Download

The Requires

 

by Antonin M

form bundle doctrine symfony image

20/01 2017

2.0.1

2.0.1.0 https://github.com/Arkounay/ImageBundle

Easier image upload form bundle with Doctrine

  Sources   Download

The Requires

 

by Antonin M

form bundle doctrine symfony image

20/01 2017

1.0.2

1.0.2.0 https://github.com/Arkounay/ImageBundle

Easier image upload form bundle with Doctrine

  Sources   Download

The Requires

 

by Antonin M

form bundle doctrine symfony image

20/01 2017

2.0.0

2.0.0.0 https://github.com/Arkounay/ImageBundle

Easier image upload form bundle with Doctrine

  Sources   Download

The Requires

 

by Antonin M

form bundle doctrine symfony image

20/01 2017

1.0.1

1.0.1.0 https://github.com/Arkounay/ImageBundle

Easier image upload form bundle with Doctrine

  Sources   Download

The Requires

 

by Antonin M

form bundle doctrine symfony image

12/01 2017

0.0.1

0.0.1.0 https://github.com/Arkounay/ImageBundle

Easier image upload form bundle with Doctrine

  Sources   Download

The Requires

 

by Antonin M

form bundle doctrine symfony image

12/01 2017

0.1

0.1.0.0 https://github.com/Arkounay/ImageBundle

Easier image upload form bundle with Doctrine

  Sources   Download

The Requires

 

by Antonin M

form bundle doctrine symfony image

12/01 2017

1.0.0

1.0.0.0 https://github.com/Arkounay/ImageBundle

Easier image upload form bundle with Doctrine

  Sources   Download

The Requires

 

by Antonin M

form bundle doctrine symfony image