symfony-cmf / media-bundle

UNMAINTAINED - Minimalistic interfaces to handle media in the context of the CMF
http://cmf.symfony.com/
30 stars 40 forks source link

Width and height not set in PHPCR Image #126

Closed danielantelo closed 8 years ago

danielantelo commented 9 years ago

Are width and height meant to be manually populated or should they be self calculated on "copyContentFromFile"?

e.g.

use Symfony\Cmf\Bundle\MediaBundle\Doctrine\Phpcr\Image;
use Symfony\Component\HttpFoundation\File\UploadedFile;

$uploadedImage = new UploadedFile($imgPath, 'test.jpg', 'image/jpeg', null, null, true);
$image = new Image();
$image->copyContentFromFile($uploadedImage);

// Failed asserting that 0 matches expected '500'.
$this->assertEquals('500', $image->getWidth()); 
dbu commented 9 years ago

this happens in a doctrine subscriber but only when the document is written - there is no event system inside the image document, and we don't want to inject Imagine or GD into the Image class.

that event listener should be enabled by default

does your test work if you persist and flush $image before checking the image width?