⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Add SimpleCropper plugin to GC



chocovo

chocovo
  • profile picture
  • Member

Posted 28 August 2015 - 22:26 PM

Hello,

 

I am trying to add SimpleCropper plugin (https://github.com/tomazdragar/SimpleCropper) to Grocery Crud edit form but I have a problem, file browser doesn't open.

 

What I did is the following:

  1.  I load all the files necesary in the header.
    <script src='....assets/backoffice/plugins/jquery-1.11.js'></script>
    <script src='....assets/backoffice/js/jquery.Jcrop.js'></script>
    <script src='....assets/backoffice/js/jquery.SimpleCropper.js'></script>
    
  2. I initialize the plugin
    <script>
       $('.cropme').simpleCropper();
    </script>
    
  3. In the controler function I use callback_edit_field to convert the input to the div I need.
    $this->grocery_crud->callback_edit_field('portfolio_image', array($this, 'cropper'));
    
  4. cropper function is:
    function cropper() {
          $div = '<div class="cropme" style="width: 400px; height: 200px; position: relative;"></div>';
          return $div;
    }
    

    All seems to be ok, the files are loaded and the div is created but nothing happen, when I click on the div, the files browser is not opened. I have no error on firebug and I don't know why it does not work.

I imagine something is wrong with GC because this plugin is very simple to use but I don't know what.

 

Thank for help.

 

 

More info: http://www.jqueryscript.net/other/jQuery-Canvas-Based-Image-Cropping-Plugin-Simple-Cropper.html


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 29 August 2015 - 17:43 PM

Well what i can understand from your problem is you are not able to incorporate your functionality of cropper with that of jquery upload thats provided by GC .. in such scenario its recommended u set your own field ... in your own desired way.. by usint callback_field..

but then mind it.. u have to manage the file uploading and stuff on your own ..!!

 

Happy GCing :)