Skip to content

Commit

Permalink
Improve UploadedFileType
Browse files Browse the repository at this point in the history
  • Loading branch information
odolbeau committed Dec 22, 2024
1 parent 2abd314 commit 89ace59
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/Admin/Form/UploadedFileType.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,10 @@ public function buildView(FormView $view, FormInterface $form, array $options):
'height' => $height,
]);

/** @var ?UploadedFile $file */
$file = $form->getData();

if ($file instanceof UploadedFile) {
$view->vars['fileUrl'] = $this->uploadedFileUrlGenerator->getImageUrl($file, $width, $height);
} else {
$view->vars['fileUrl'] = "https://placehold.co/{$width}x{$height}?text=Choisir une image";
}

$view->vars['fileUrl'] = $this->uploadedFileUrlGenerator->getImageUrl($file, $width, $height);
$view->vars['preview_width'] = $width;
$view->vars['preview_height'] = $height;

Expand Down

0 comments on commit 89ace59

Please sign in to comment.