anime-db / form-type-image-bundle
Image upload form type
Installs: 9
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Language:JavaScript
Requires
- php: >=5.4.0
- symfony/symfony: >=2.8.0
Requires (Dev)
Suggests
- sonata-project/admin-bundle: Allows upload images in SonataAdminBundle
This package is auto-updated.
Last update: 2024-10-15 20:33:56 UTC
README
Image upload form type
Installation
Pretty simple with Composer, run:
composer require anime-db/form-type-image-bundle
Add FormTypeImageBundle to your application kernel
// app/AppKernel.php public function registerBundles() { return array( // ... new AnimeDb\Bundle\FormTypeImageBundle\AnimeDbFormTypeImageBundle(), // ... ); }
Configuration
Default config
anime_db_cache_time_keeper: web_path: '/upload/' # Upload images directory: %kernel.root_dir%/../web/upload/ authorized: true # Only authorized users can upload images constraint: files_limit: 10 # Limiting the number of simultaneous file upload max_size: null # Max file size. Example: 2M min_width: 0 # Minimum image width min_height: 0 # Minimum image height max_width: 0 # Maximum image width max_height: 0 # Maximum image height
Add form template
twig: form: resources: [ 'AnimeDbFormTypeImageBundle:Form:fields.html.twig' ]
Add form templates for SonataDoctrineORMAdminBundle
sonata_doctrine_orm_admin: templates: form: [ 'AnimeDbFormTypeImageBundle:Form:sonata_admin_fields.html.twig' ]
Usage
use AnimeDb\Bundle\FormTypeImageBundle\Form\Type\ImageType; use AnimeDb\Bundle\FormTypeImageBundle\Form\Type\ImageCollectionType; $form = $this ->createFormBuilder() ->add('cover', ImageType::class) ->add('covers', ImageCollectionType::class);