https://github.com/anime-db/form-type-image-bundle
Image upload form type
https://github.com/anime-db/form-type-image-bundle
component php
Last synced: 2 months ago
JSON representation
Image upload form type
- Host: GitHub
- URL: https://github.com/anime-db/form-type-image-bundle
- Owner: anime-db
- License: mit
- Created: 2016-04-20T07:18:35.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-05-25T14:36:21.000Z (about 9 years ago)
- Last Synced: 2025-02-14T21:54:58.727Z (4 months ago)
- Topics: component, php
- Language: JavaScript
- Size: 113 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://packagist.org/packages/anime-db/form-type-image-bundle)
[](https://packagist.org/packages/anime-db/form-type-image-bundle)
[](https://packagist.org/packages/anime-db/form-type-image-bundle)
[](https://travis-ci.org/anime-db/form-type-image-bundle)
[](https://scrutinizer-ci.com/g/anime-db/form-type-image-bundle/?branch=master)
[](https://scrutinizer-ci.com/g/anime-db/form-type-image-bundle/?branch=master)
[](https://insight.sensiolabs.com/projects/f83dabf8-d5b0-4586-b254-af742df345c6)
[](https://packagist.org/packages/anime-db/form-type-image-bundle)# Image upload form type
## Installation
Pretty simple with [Composer](http://packagist.org), run:
```sh
composer require anime-db/form-type-image-bundle
```Add FormTypeImageBundle to your application kernel
```php
// app/AppKernel.php
public function registerBundles()
{
return array(
// ...
new AnimeDb\Bundle\FormTypeImageBundle\AnimeDbFormTypeImageBundle(),
// ...
);
}
```## Configuration
Default config
```yml
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
```yml
twig:
form:
resources: [ 'AnimeDbFormTypeImageBundle:Form:fields.html.twig' ]
```Add form templates for [SonataDoctrineORMAdminBundle](https://github.com/sonata-project/SonataDoctrineORMAdminBundle)
```yml
sonata_doctrine_orm_admin:
templates:
form: [ 'AnimeDbFormTypeImageBundle:Form:sonata_admin_fields.html.twig' ]
```## Usage
```php
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);
```