monsieurbiz / SyliusRichEditorPlugin

This plugin add a rich editor on fields to be able to drag and drop elements and edit it.
MIT License
66 stars 38 forks source link

Gives the possibility to define specific constraints on images or videos #190

Closed delyriand closed 1 year ago

delyriand commented 1 year ago

For example, I want to define a custom maxSize in the Image constraint:

->add('image', ImageType::class, [
    'label' => 'app.form.image',
    'constraints' => [
        new Assert\Image(['maxSize' => '2M']),
    ],
])

And add the event listener with this code:

$options['constraints'] = RichEditorConstraints::getImageConstraints(
    $data,
    'image',
    $options['required'] ?? true,
    $options['constraints'] ?? []
);