onadrog / imageconverterbundle
A simple FormType that convert images into WebP format
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- doctrine/doctrine-bundle: ^2.4
- doctrine/orm: ^2.9
- symfony/asset: ^5.3
- symfony/cache: ^5.3
- symfony/config: ^5.3
- symfony/dependency-injection: ^5.3
- symfony/event-dispatcher: ^5.3
- symfony/form: ^5.3
- symfony/mime: ^5.3
- symfony/orm-pack: ^2.1
- symfony/property-access: ^5.3
- symfony/runtime: ^5.3
- symfony/string: ^5.3
- symfony/twig-bundle: ^5.3
- symfony/uid: ^5.3
- symfony/validator: ^5.3
- twig/twig: ^3.3
Requires (Dev)
- dbrekelmans/bdi: ^0.3.0
- doctrine/annotations: ^1.13
- doctrine/doctrine-fixtures-bundle: ^3.4
- doctrine/doctrine-migrations-bundle: ^3.1
- friendsofphp/php-cs-fixer: ^3.0
- phpstan/phpstan: ^0.12.94
- phpstan/phpstan-symfony: ^0.12.41
- phpunit/phpunit: ^9.5
- symfony/browser-kit: ^5.3
- symfony/console: ^5.3
- symfony/css-selector: ^5.3
- symfony/framework-bundle: ^5.3
- symfony/http-kernel: ^5.3
- symfony/maker-bundle: ^1.33
- symfony/panther: ^1.1
- symfony/phpunit-bridge: ^5.3
- symfony/yaml: ^5.3
Suggests
- symfony/maker-bundle: Needed for command onadrog:make:entity
- symfony/yaml: Needed for command onadrog:dump:config
README
Convert your images into WebP format using the symfony form Component and Doctrine bundle to persist data.
Requirements
Prod:
- PHP >= 8.0
- GDImage
Installation:
composer require onadrog/imageconverterbundle php bin/console asset:install
Minimal configuration
This package use php8 attributes.
Use ImageUpload
and ImageUploadProperties
attributes as follow.
// src/Entity/Foo.php namespace App\Entity; // ... use Onadrog\ImageConverterBundle\Mapping\Attribute as Onadrog; /** * @ORM\Entity(repositoryClass=FooRepository::class) */ #[Onadrog\ImageUpload] class Foo { // ... private $fileName; private $fileSlug; /** * @ORM\Column(type="json") */ private ?array $fileDimension = []; /** * @ORM\Column(type="json") */ private ?array $mimeTypes = []; private $fileAlt; #[Onadrog\ImageUploadProperties(name: 'fileName', slug: 'fileSlug', alt: 'fileAlt', dimension: 'fileDimension', mimeTypes: 'mimeTypes')] private $file; }
Once done use the ImageConverterType
in your FormBuilder related to the property where the ImageUploadProperties
is mapped (here file
) .
// src/Form/FooType.php namespace App\Foo\Form; // ... use Onadrog\ImageConverterBundle\Form\Type\ImageConverterType; class FooType extends AbstractType { //.. public function builForm(FormBuilder $builder, array $options) { // ... $builder->add('file', ImageConverterType::class); } }
Twig extension:
{% extends 'base.html.twig' %} {% block body %} {{ image_converter_img(foo) }} {% endblock %}
Configuration default values:
# config/packages/image_converter.yaml image_converter: media_uploads_path: "%kernel.project_dir%/public/uploads/media/" namer: "default" quality: 80 public_path: "/uploads/media/" remove_orphans: true keep_original: false use_js: false
Console commands:
onadrog:debug:config onadrog:dump:config onadrog:make:entity [options] <args>
For more informations read the Wiki
Donate:
Eth address: 0xB374931cc925042731d971C07708be68B115BC0d