dustin10 / VichUploaderBundle

A simple Symfony bundle to ease file uploads with ORM entities and ODM documents.
MIT License
1.85k stars 520 forks source link

Custom VichImageType #1394

Closed florent6001 closed 1 year ago

florent6001 commented 1 year ago

|---------------- | ------ | Bundle version | "vich/uploader-bundle": "^2.1" | Symfony version | 6.3.0 | PHP version | 8.2.7

Support Question

Hi, actually i'm trying to implement a logo features in a form, all is working pretty good after some little issue with serialization. But now, i'm facing a problem with VichImageType, actually. If we upload a big image, the image will take all the screen and dont fit to the div. I tryied to add a custom class w-100 on my FormType but it didn't do the trick.

Someone have maybe an idea how to change it ? Here is my current code:

->add('imageFile', VichImageType::class, [
                'label' => $this->translator->trans('Company logo'),
                'required' => false,
            ])
<div class="col-md-6">
            {{ form_row(form.imageFile) }}
        </div>

Here is a screenshot of the result:

Capture d’écran 2023-06-28 à 04 28 10
garak commented 1 year ago

You can use a CSS rule with max-width and max-heigth

florent6001 commented 1 year ago

I don't want to use CSS in that case, i would like to change the html structure.

garak commented 1 year ago

So, you can override the template