Resize image after upload using imagine

This commit is contained in:
Jannis Portmann 2022-01-12 17:51:45 +01:00
parent 27474ad2ea
commit 72418dd5a4
2 changed files with 42 additions and 1 deletions

View file

@ -10,6 +10,7 @@ use App\Repository\WishRepository;
use App\Service\PlzToCoordinate;
use App\Service\DistanceCalculator;
use App\Service\PhotoResizer;
use App\Service\OfferPhotoHelper;
use Doctrine\ORM\EntityManagerInterface;
@ -24,9 +25,10 @@ class OfferController extends AbstractController
{
private $entityManager;
public function __construct(EntityManagerInterface $entityManager)
public function __construct(EntityManagerInterface $entityManager, PhotoResizer $photoresizer)
{
$this->entityManager = $entityManager;
$this->photoresizer = $photoresizer;
}
#[Route('/offers', name: 'offers')]
@ -62,6 +64,8 @@ class OfferController extends AbstractController
$this->entityManager->persist($offer);
$this->entityManager->flush();
$this->photoresizer->resize($photoDir.'/'.$offer->getPhotoFilename());
$this->addFlash("success", "Successfully added the new offer!");
return $this->redirectToRoute('offers');
}