Commit 3e2b6765 authored by Ludwig Ruderstaller's avatar Ludwig Ruderstaller

Merge branch 'feature/fix-resizing' into 'master'

fix resizing bug, change arrays to short syntax



See merge request !1
parents ff4c7739 2bda4f61
# IntelliJ project files
.idea
*.iml
......@@ -42,9 +42,7 @@ class ImageController extends CwdController
$media = $service->create($request->files->get('file'), true);
$service->flush();
$data = array(
'link' => $this->getUrl($media, 1000),
);
$data = ['link' => $this->getUrl($media, 1000)];
return JsonResponse::create($data);
}
......@@ -61,10 +59,10 @@ class ImageController extends CwdController
$images = [];
foreach ($medias as $media) {
$images[] = array(
$images[] = [
'url' => $this->getUrl($media, 1000),
'thumb' => $this->getUrl($media, 150, 150, true),
);
];
}
return new JsonResponse($images);
......
......@@ -41,7 +41,7 @@ class ResizeUploadedImagesSubscriber implements EventSubscriberInterface
*/
public static function getSubscribedEvents()
{
return array(FormEvents::PRE_SUBMIT => 'preSubmit');
return [FormEvents::PRE_SUBMIT => 'preSubmit'];
}
/**
......@@ -84,6 +84,10 @@ class ResizeUploadedImagesSubscriber implements EventSubscriberInterface
$newImgTag = str_replace($heightMatches[0], '', $newImgTag);
}
if ($width == null && $height == null) {
continue;
}
$image->cropResize($width, $height);
$newUrl = $image->__toString();
......
......@@ -51,6 +51,6 @@ class FroalaType extends TextareaType
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefault('attr', array('class' => 'cwd-froala'));
$resolver->setDefault('attr', ['class' => 'cwd-froala']);
}
}
......@@ -38,16 +38,16 @@ class FroalaExtension extends \Twig_Extension
*/
public function getFunctions()
{
return array(
return [
new \Twig_SimpleFunction(
'cwd_froala_javascript',
array($this, 'getJavascript'),
array(
'is_safe' => array('html'),
[$this, 'getJavascript'],
[
'is_safe' => ['html'],
'needs_environment' => true,
)
]
),
);
];
}
/**
......@@ -56,7 +56,7 @@ class FroalaExtension extends \Twig_Extension
*
* @return string
*/
public function getJavascript(\Twig_Environment $twig, $runtimeOptions = array())
public function getJavascript(\Twig_Environment $twig, $runtimeOptions = [])
{
$config = array_merge(
$this->config['default_js_options'],
......@@ -64,7 +64,7 @@ class FroalaExtension extends \Twig_Extension
$runtimeOptions
);
return $twig->render('CwdFroalaBundle::script.html.twig', array('config' => $config));
return $twig->render('CwdFroalaBundle::script.html.twig', ['config' => $config]);
}
/**
......
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