Commit 6f2030e6 authored by Ludwig Ruderstaller's avatar Ludwig Ruderstaller

Symfony >3.0 Fix

parent 1d0e0c56
......@@ -13,6 +13,7 @@ use Cwd\MediaBundle\Form\Transformer\MediaTransformer;
use Cwd\MediaBundle\Model\Entity\Media;
use Cwd\MediaBundle\Service\MediaService;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
......@@ -71,6 +72,7 @@ class ImageType extends AbstractType
{
$resolver->setDefaults(
array(
'attr' => ['class' => 'image-upload'],
'validation_groups' => array('default'),
'data_class' => 'Cwd\MediaBundle\Model\Entity\Media',
'cascade_validation' => true,
......@@ -78,13 +80,18 @@ class ImageType extends AbstractType
);
}
public function getBlockPrefix()
{
return 'cwd_image_type';
}
/**
*
* @return string
*/
public function getParent()
{
return 'file';
return FileType::class;
}
/**
......
......@@ -462,7 +462,10 @@ class MediaService
$path = $this->createDirectoryByFilename($md5);
$target = $path.'/'.$md5.'.'.$format;
Image::open($input)
$data = file_get_contents($input);
$retval = Image::fromData($data)
->useFallback(false)
->setForceCache(false)
->cropResize($this->getConfig('converter')['size']['max_width'], $this->getConfig('converter')['size']['max_height'])
->save($target, $format, $this->getConfig('converter')['quality']);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment