Answer the question
In order to leave comments, you need to log in
How to add images to Sonata Admin?
There are two entities:
Answer the question
In order to leave comments, you need to log in
I am using VichUploaderBundle to save images to an entity. It turns out quite convenient (I don’t like the fact that you can’t directly display item.picture in twig, but you have to display it through vich_uploader_asset(item, 'image')).
And in the admin panel, I display the thumbnail of the picture through the help
$helper = $this->getConfigurationPool()->getContainer()->get('vich_uploader.templating.helper.uploader_helper');
$src = $helper->asset($this->getSubject(), 'image');
$formMapper->setHelps([
'picture' => "<img src=\"$src\" width=\"100\">",
]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question