comur / comurimagebundle Goto Github PK
View Code? Open in Web Editor NEWImage upload / crop bundle for Symfony2
Image upload / crop bundle for Symfony2
Hi.
the modal is not responsive, and in mobiles is not functional. There is a fixed width to 850px, but i don't know why. There is a reason for that? If you delete it, the modal works perfectly.
Cheers,
Sergio
Hey there,
I installed the lates dev-master as described in the documentation, but can't get it to work.
If I hover over the placeholder Image the Edit button appears, but pressing it doesn't work.
In the console I see this error when pressing the Edit button:
TypeError: $(...).fileupload is not a function
Empty string passed to getElementById().
Jquery and all necessary files are loaded and active. What could be the problem?
Thanks for help.. :)
If set to true or false, I always get same images with same definition ;)
Hie can you push png transparent fix in the branches 1.0.x (with boostrap 3.0) please
If i upload an image which has exact same size as minWidht or minHeight, it adds a black line at left or top because jcrop sends:
x:-0.624996185302134
w:300.625
instead of
x: 0
w: 300
for an image width = 300 and minWidth = 300
Hi all!!!
It seems that placehold.io doesn't work, the web is offline. It can be replaced by placehold.it, but I recommend to use holder.js, thus the bundle doesn't depend on outer functions.
Hi!
I'm experimenting a weird behavior when uploading images, when I upload the first image upload one image, perfect; but when upload the second two images are uploaded, and so on; third image tree images uploaded.
What could possibly be happening?
While moving the project to production i noticed that the POST after uploading an image returns 404:
"Failed to load resource: the server responded with a status of 404 (Not Found) http://somedomain.com/upload/"
The not-found path is defined in routing.yml
comur_api_upload:
pattern: /upload
In debug_mode everything works just fine, at both local and external server, but in production mode the error is thrown.
Anyone knows what could be the problem? Just in case is relative to the issue, i also added a rewrite rule to get rid of the "app.php" part of the url.
Thanks,
Having an issue when modal appear, i am not able to upload an img, Chrome gives me an error 500, mkdir: permission denied.
I work under mac os 10.7.5 (Lyon), I have been searching around and tried a couple of thing.
I gave apache the permission is needed:
sudo chown -R _www:_www web/uploads/
chmod -R g+rw web/uploads/
sudo chgrp -R _www web/uploads/
I tried to put my username in _www group:
sudo dseditgroup -o edit -a $USER -t user _www
And put _www in wheel:
sudo dseditgroup -o edit -a _www -t user wheel
But nothing work, do you have any idea on how to solve this?
INFO - Matched route "comur_api_image_library" (parameters: "_controller": "Comur\ImageBundle\Controller\UploadController::getLibraryImagesAction", "_route": "comur_api_image_library")
INFO - Populated SecurityContext with an anonymous Token
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::configure".
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\DumpListener::configure".
DEBUG - Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\SessionListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\FragmentListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\TranslatorListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\Security\Http\Firewall::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "NewBlog\AdminBundle\Listener\DoctrineExtensionListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "Symfony\Bundle\AsseticBundle\EventListener\RequestListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "NewBlog\AdminBundle\Listener\DoctrineExtensionListener::onLateKernelRequest".
DEBUG - Notified event "kernel.controller" to listener "Symfony\Bundle\FrameworkBundle\DataCollector\RouterDataCollector::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "Symfony\Component\HttpKernel\DataCollector\RequestDataCollector::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ControllerListener::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ParamConverterListener::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\HttpCacheListener::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\SecurityListener::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\TemplateListener::onKernelController".
CRITICAL - Uncaught PHP Exception Symfony\Component\Debug\Exception\ContextErrorException: "Warning: mkdir(): Permission denied" at /Users/tamarabollinger/Sites/new_blog/vendor/comur/image-bundle/Comur/ImageBundle/Controller/UploadController.php line 277
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::configure".
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\DumpListener::configure".
DEBUG - Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\SessionListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\FragmentListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\TranslatorListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "Symfony\Component\Security\Http\Firewall::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "NewBlog\AdminBundle\Listener\DoctrineExtensionListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "Symfony\Bundle\AsseticBundle\EventListener\RequestListener::onKernelRequest".
DEBUG - Notified event "kernel.request" to listener "NewBlog\AdminBundle\Listener\DoctrineExtensionListener::onLateKernelRequest".
DEBUG - Notified event "kernel.controller" to listener "Symfony\Bundle\FrameworkBundle\DataCollector\RouterDataCollector::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "Symfony\Component\HttpKernel\DataCollector\RequestDataCollector::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ControllerListener::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ParamConverterListener::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\HttpCacheListener::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\SecurityListener::onKernelController".
DEBUG - Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\TemplateListener::onKernelController".
Hi
i want to edit image profile using ComurImageBundle but i don't know what should i write is any documentation or any code already used.thanks
Here is my entityType.php code
->add('imgName', 'comur_image', array( 'uploadConfig' => array( 'generateFilename' => false, 'showLibrary' => false, 'uploadUrl' => $myEntity->getUploadRootDir(), 'webDir' => $myEntity->getUploadDir(), 'fileExt' => '*.jpg;*.gif;*.png;*.jpeg', ), 'cropConfig' => array( 'minWidth' => 200, 'minHeight' => 200, 'aspectRatio' => true, 'cropRoute' => 'comur_api_crop', 'forceResize' => true, ) ))
So with or with the 'generateFilename' => false
set to true or false it always sets the filename to a super long ugly string like 271ed3895ece9653fb0c31a6793142b8e811d404.jpg
Hello,
I have installed your bundle that is very great but I have a problem when I click on Edit button :
Uncaught TypeError: $(...).fileupload is not a function
Here is my versions :
I include Twig like this :
{% include "ComurImageBundle:Form:croppable_image_modal.html.twig" with {'include_jquery': false, 'include_bootstrap': false} %}
I have installed assets and all JS are present in web/bundles folder.
If I comment .fileupload from comur.imagelibrary.js, I have another problem with function modal from bootstrap : Uncaught TypeError: $(...).modal is not a function. Very strange...
But if I copy this line ($('#image_upload_modal').modal('show');) from comur.imagelibrary.js to the end of my HTMl document, it works and modal appears.
I don't understand what it's happening...
If someone has an idea, thank you.
Add options to support multiple file upload with a new field type like comur_gallery and store them in an array to keep it simple.
When I crop a file png with background transparent
I have a black background
I think you must add imagealphablending on each new layer.
Have to find a way to delete images when they are not used anymore.
2 possibilities:
Any way, we have to create a service to get all image types (cropped, thumbs) related to an image.
Hello i having this problem: "Uncaught SyntaxError: Unexpected token i" when I click on the "Edit" button where I included the image widget in my view.
I use the branch : "comur/image-bundle": "1.0.*@dev"
and bootstrap 3.
In my layout I used {% include "ComurImageBundle:Form:croppable_image_modal.html.twig" with {'include_jquery': false, 'include_bootstrap': false} %} since i'm already including a jquery script and bootstrap 3. I made sure the include was after the jquery script.
When i click on the error msg in the navigator console. i don't get a specific line number, so i have no idea where the error is coming from.
Cropped image name will be configurable, it make big effort when some dynamics image directory generate after upload and cropped.
For Ex:
if(isset($config['cropConfig']['useFileNameUnique']) && $config['cropConfig']['useFileNameUnique'] != ""){
$ext = pathinfo($imageName, PATHINFO_EXTENSION);
$imageName = sha1(uniqid(mt_rand(), true)).'.'.$ext;
}
What you think about this one ?
Hello,
I have a problem to upload the image to the server. I have installed the bundle, pop up displays correctly when I selected an image, it is uploaded to the server, but in return it does not appear in the pop up.
Looking at the console I noticed an error in routing. The URL I use to upload the files is as follows:
http: //localhost/congo-job/cj-symf/web/app_dev.php/demo/imageTest/new
but in the console I get this error:
Failed to load resource: the server responded with a status of 404 (Not Found)
http: //localhost/uploads/test/5bbfd314905a0b267d0b3f5c36ef0f8897415f42.jpg 1435321243541?
I already noticed that the path of the url are not correct.
Can anyone help me?
My entity :
Hello,
I have a problem to upload the image to the server. I have installed the bundle, pop up displays correctly when I selected an image, it is uploaded to the server, but in return it does not appear in the pop up.
Looking at the console I noticed an error in routing.
The URL I use to upload the files is as follows:
http: //localhost/congo-job/cj-symf/web/app_dev.php/demo/imageTest/new
but in the console I get this error:
Failed to load resource: the server responded with a status of 404 (Not Found)
http: //localhost/uploads/test/5bbfd314905a0b267d0b3f5c36ef0f8897415f42.jpg 1435321243541?
I already noticed that the path of the url are not correct.
Can anyone help me?
Hello,
I have a problem to upload the image to the server. I have installed the bundle, pop up displays correctly when I selected an image, it is uploaded to the server, but in return it does not appear in the pop up.
Looking at the console I noticed an error in routing.
The URL I use to upload the files is as follows:
http: //localhost/congo-job/cj-symf/web/app_dev.php/demo/imageTest/new
but in the console I get this error:
Failed to load resource: the server responded with a status of 404 (Not Found)
http: //localhost/uploads/test/5bbfd314905a0b267d0b3f5c36ef0f8897415f42.jpg 1435321243541?
I already noticed that the path of the url are not correct.
Can anyone help me?
id; } /** * Set photo * * @param string $photo * @return Image */ public function setPhoto($photo) { $this->photo = $photo; return $this; } /** * Get photo * * @return string */ public function getPhoto() { return $this->photo; } public function getUploadRootDir() { // absolute path to your directory where images must be saved return str_replace("\\", '\\\\', __DIR__.'/../../../../web/'.$this->getUploadDir()); } public function getUploadDir() { return 'uploads/test'; } public function getAbsolutePath() { return null === $this->photo ? null : $this->getUploadRootDir().'/'.$this->photo; } public function getWebPath() { return null === $this->photo ? null : '/'.$this->getUploadDir().'/'.$this->photo; } /** * Set originalImage * * @param string $originalImage * @return Image */ public function setOriginalImage($originalImage) { $this->originalImage = $originalImage; return $this; } /** * Get originalImage * * @return string */ public function getOriginalImage() { return $this->originalImage; } ``` } ImageType: getForm()->getData(); ``` $builder ->add('photo', 'comur_image', array( 'uploadConfig' => array( 'uploadRoute' => 'comur_api_upload', //optional 'uploadUrl' => $myEntity->getUploadRootDir(), // required - see explanation below (you can also put just a dir path) 'webDir' => $myEntity->getUploadDir(), // required - see explanation below (you can also put just a dir path) 'fileExt' => '*.jpg;*.gif;*.png;*.jpeg', //optional //'libraryDir' => null, //optional 'libraryRoute' => 'comur_api_image_library', //optional 'showLibrary' => true, //optional 'saveOriginal' => 'originalImage' //optional ), 'cropConfig' => array( 'minWidth' => 200, 'minHeight' => 200, 'aspectRatio' => true, //optional 'cropRoute' => 'comur_api_crop', //optional 'forceResize' => false, //optional 'thumbs' => array( //optional array( 'maxWidth' => 200, 'maxHeight' => 200, 'useAsFieldImage' => true //optional ) ) ) )) ; } /** * @param OptionsResolverInterface $resolver */ public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setDefaults(array( 'data_class' => 'Acme\DemoBundle\Entity\Image' )); } /** * @return string */ public function getName() { return 'acme_demobundle_image'; } ``` } Image\new.html.twig : {% extends '::base.html.twig' %} {% block javascripts %} ``` <script src="{{ asset('bundles/fosjsrouting/js/router.js') }}"></script> <script src="{{ path('fos_js_routing_js', {"callback": "fos.Router.setData"}) }}"></script> ``` {% endblock %} {% block body -%} ``` {% include "ComurImageBundle:Form:croppable_image_modal.html.twig"%}Hello,
Gallery widget doesn't send data with selected images. POST request doesn't have data with images. To database is saving empty array.
Can you help me with this issue?
Hi all.
I've a syntax error in the options parsing in twig:
fields.html.twig line 54: {{ options | json_encode() | raw }}
I think that uploadConfig object isn't properly parse, because the slash in the routes are not escaped (they are '' instead of '').
Is this possible?
When using Assert/NotBlank on image field, the label is not colored and error isn't shown. Example of correct behaviour (title) and broken one (image):
Add multiple file upload support to gallery widget
shows error - Uncaught SyntaxError: Unexpected token x - when i click edit button,.. i think it has to do something with parseJson
Hello, when i add {% include "ComurImageBundle:Form:croppable_image_modal.html.twig"%} it shows me nothing and when i add {% include "ComurImageBundle:Form:croppable_image_modal.html.twig" with {'include_jquery': false, 'include_bootstrap': false} %} it works without style, how to fix that please ?
Hello,
i have all config write but with the type Single image or gallery i have the same error in console :
Uncaught TypeError: undefined is not a function comur.imagelibrary.js:60 initializeImageManager comur.imagelibrary.js:60 (anonymous function) (index):347 jQuery.event.dispatch 772ad89_part_5.js:1 elemData.handle 772ad89_part_5.js:1 POST http://127.0.0.1:8080/app_dev.php/image-library 500 (Internal Server Error) 772ad89_part_5.js:1 send 772ad89_part_5.js:1 jQuery.extend.ajax 772ad89_part_5.js:1 initializeImageManager comur.imagelibrary.js:27 (anonymous function) (index):347 jQuery.event.dispatch 772ad89_part_5.js:1 elemData.handle
I have allright config, and this bundle is seems to be really good ๐
Hi a try use the bundle when i click on edit my navegator says:
Uncaught TypeError: undefined is not a function
on $('#image_upload_file').fileupload
i include {% include "ComurImageBundle:Form:croppable_image_modal.html.twig" with {'include_jquery': true, 'include_bootstrap': false} %} do you have any idea?
Hi again.
There is an issue with png files that has transparent background. I have resolved it.
Hi,
Thank you for your help @comur ,i already use it and it works fine but now i need to make like the first capture
Is there a way that the crop rectangle - by default, initially - simply fills the entire image? That way the crop action will be optional, whoever decides to do so.
Or, alternatively - is there a way to disable the cropping entirely?
Hi, first of all, thank you for this bundle.
It would be nice if you add this dependency in composer :
"jms/translation-bundle": "dev-master".
A function in comur.imagelibrary.js is adding a text that is not translated.
function destroyImageManager(){
$('#image_upload_file').fileupload('destroy');
destroyJCrop();
$('#image_crop_go_now').unbind('click');
$('#image_preview').html('
Please select or upload an image
');Hi,
When I want to use the image gallery widget I get this error in the browser console. I have to download jquery ui and add it to the croppable_image_modal.html.twig template to get it work. I use jquery v2.1.4, I get this error event if I set the "include_jquery" parameter to TRUE. Don't think it's normal or if I've miss something ?
Thx
Could this library potentially work with sonata media ?
May be as some extension as CoopTilleulsCKEditorSonataMediaBundle
I manage to get the holder displayed properly but when I click on Modify, the background become darker as it would be expected but no modal and no error / warning / anything to debug.
Jquery 2.1
Bootstrap 3.2.2
Query UI Widget 1.10.3+amd (provided by your bundle)
Thanks for your help!
Hello !
I hava a problem when I want to crop my uploaded image.
First, I don't see all my image.
Second, I can't move the jCrop zone and the jCrop zone have a very little height.
I hav also a list bullet at the left...
I use configuration from READMME.md.
What am I doing wrong ? Thank you for your help.
Hi!
I've been playing around with this bundle (excellent work btw), and I'm kind of lost trying to find out the right direction to implement remove image from gallery.
Has anybody worked on this feature before? Can I ask for some directions on this?
Thanks in advance!
Hi,
I'm facing some troubles overriding fields.html.twig
I've already copied ComurImageBundle/views/Form templates and place it into app/Resources folder.
In line 91 I want to override
i class="icon icon icon-remove" data-delete="image"
to:
i class="glyphicon glyphicon-remove-circle" data-delete="image"
But the template is always rendering class="icon icon icon-remove" instead class="glyphicon glyphicon-remove-circle" previously defined in app/Resources/ComurImageBundle/views/Form/fields.html.twig
Any thoughts?
Align image delete icon to top left corner of image container
Crop engine set jpeg quality to 100 (as mentioned in EXIF of result image). I found option 'jpeg_quality' in UploadHandler.php at 883 line, but setting this option to field definition doesn't do any changes.
I tried to set 'jpeg_quality' at these places:
->add('picture', 'comur_image', array(
'required' => false,
'uploadConfig' => array(
'uploadRoute' => 'comur_api_upload',
'uploadUrl' => $object->getPictureUploadRootDir(),
'webDir' => $object->getPictureUploadDir(),
'fileExt' => '*.jpg;*.gif;*.png;*.jpeg',
'libraryDir' => null,
'libraryRoute' => 'comur_api_image_library',
'showLibrary' => true,
'saveOriginal' => 'originalPicture'
),
'cropConfig' => array(
'minWidth' => 640,
'minHeight' => 480,
'jpeg_quality' => 30, // jpeg_quality ?
'aspectRatio' => true,
'cropRoute' => 'comur_api_crop',
'forceResize' => false,
'thumbs' => array(
array(
'maxWidth' => 180,
'maxHeight' => 400,
'jpeg_quality' => 30, // jpeg_quality ?
'useAsFieldImage' => true //optional
)
)
)
))
It will be logical to set jpeg_quality inside thumbs array, for separate option for all thumbs.
Hello,
I really want to know about image store based on last insert id,
For Ex:
-> Current images table have 3 records.
-> Now i am going to upload new one.
-> Newly uploaded image stored would be on uploads/{4}/2sdf3asdf4as.jpg
->{4} will be last insert id
Actually standard symfony provide lifecycle callback so we can do that, but i don't know how to do with this bundle.
I really love this bundle it is awesome ๐
after install with composer click add or edit not responding
and modal not open
plz help me.
How can I change uploadRoute to my custom controller?
I have changed uploadRoute to my custom controller but it doesn't work.
$myEntity = $builder->getForm()->getData();
$builder->add('photoName', 'comur_image', array(
'uploadConfig' => array(
'uploadRoute' => 'custom_route', //optional
'uploadUrl' => $myEntity->getUploadRootDir(), // required - see explanation below (you can also put just a dir path)
'webDir' => $myEntity->getUploadDir(), // required - see explanation below (you can also put just a dir path)
'fileExt' => '.jpg;.gif;.png;.jpeg', //optional
'libraryDir' => null, //optional
'libraryRoute' => 'comur_api_image_library', //optional
'showLibrary' => true, //optional
'saveOriginal' => 'photoName' //optional
),
'cropConfig' => array(
'minWidth' => 100,
'minHeight' => 100,
'aspectRatio' => false, //optional
'cropRoute' => 'comur_api_crop', //optional
'forceResize' => true, //optional
'thumbs' => array(//optional
array(
'maxWidth' => 500,
'maxHeight' => 300,
'useAsFieldImage' => true //optional
)
)
)
))
;
There's a mismatch in progress bar selector in "comur.imagelibrary.js" and "croppable_image_modal.html.twig".
"comur.imagelibrary.js" => $('#image_upload_file_progress .progress-bar').css('width',progress + '%');
"croppable_image_modal.html.twig" =>
some news to update to the latest version jquery.Jcrop.js 2?
Nothing happens when you select a file. I see where it calls _initIframeSettings in jquery.fileupload.js but that doesn't seem to do much. In other browsers it doesn't call that method, it uses XHR upload instead and that seems to work fine.
edit: this is actually IE9 issue, it works with XHR in IE10
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.