Using TYPO3.Media
So I wanted to have some nice shiny images in my Application. After a first try using \TYPO3\FLOW3\Resource\Resource directly in my Model (which worked fine, but left me alone when I wanted to have thumbnails), I checked the TYPO3.Media package, and tada!
So here we go:
Install the needed packages
TYPO3.Media depends on Imagine
$> ./flow3 package:import Imagine $> ./flow3 package:import TYPO3.Media
Add the Image to your Model
class Event { //... /** * * @var \TYPO3\Media\Domain\Model\Image * @ORM\OneToOne(cascade={"all"}, orphanRemoval=true) * */ protected $image; //... }
Provide a form to edit it
Don't forget to add enctype="multipart/form-data" to your form.
We're using the TYPO3.Media ImageViewHelper for a thumbnail.
{namespace media=TYPO3\Media\ViewHelpers} <f:form enctype="multipart/form-data" action="update" name="event" object="{event}"> <!-- ... --> <f:if condition="{event.image}"> <media:image image="{event.image}" alt="An image, AN IMAGE!!!" maximumWidth="50" /> </f:if> <f:form.upload property="image.resource" /> <!-- ... --> </f:form>












