Skip to content

Commit 282e88c

Browse files
committed
Added cropper for ImageType. Added thumbnail_width, thumbnail_height, cropper_ratio options.
1 parent 4e0c00b commit 282e88c

12 files changed

+10951
-234
lines changed

Diff for: Form/ImageType.php

+34
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111

1212
namespace Glavweb\UploaderDropzoneBundle\Form;
1313

14+
use Symfony\Component\OptionsResolver\OptionsResolver;
15+
use Symfony\Component\Form\FormInterface;
16+
use Symfony\Component\Form\FormView;
17+
1418
/**
1519
* Class ImageType
1620
*
@@ -26,4 +30,34 @@ public function getBlockPrefix()
2630
{
2731
return 'cms_media_image';
2832
}
33+
34+
/**
35+
* @param FormView $view
36+
* @param FormInterface $form
37+
* @param array $options
38+
*/
39+
public function buildView(FormView $view, FormInterface $form, array $options)
40+
{
41+
parent::buildView($view, $form, $options);
42+
43+
$view->vars['thumbnailWidth'] = $options['thumbnail_width'];
44+
$view->vars['thumbnailHeight'] = $options['thumbnail_height'];
45+
$view->vars['cropperRatio'] = $options['cropper_ratio'];
46+
}
47+
48+
/**
49+
* @param OptionsResolver $resolver
50+
*/
51+
public function configureOptions(OptionsResolver $resolver)
52+
{
53+
$resolver->setDefaults([
54+
'compound' => false,
55+
'requestId' => null,
56+
'context' => null,
57+
'thumbnail_filter' => null,
58+
'thumbnail_width' => 250,
59+
'thumbnail_height' => 250,
60+
'cropper_ratio' => 1
61+
]);
62+
}
2963
}

0 commit comments

Comments
 (0)