Coder Social home page Coder Social logo

breithbarbot / cropper-bundle Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 3.0 557 KB

Simple cropping tool for Symfony

License: MIT License

PHP 7.68% CSS 1.49% JavaScript 86.12% Twig 4.39% SCSS 0.32%
crop cropping image avatar upload symfony-bundle form-types symfony php

cropper-bundle's Introduction

Hi there ๐Ÿ‘‹๐Ÿพ

  • ๐Ÿ”ญ I'm currently working on great projects
  • ๐Ÿ“ซ How to reach me:

cropper-bundle's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

cropper-bundle's Issues

Twig_Extension deprecated

Any plans for an update not depending on the now deprecated Twig_Extension?
For use with Symfony >=4.4

Override template

Hello and thank you for this bundle!

I would like to replace the template "fields.html.twig" but I can't.

I have however created a "bundles" folder with the template inside, maybe I am doing it wrong?

How would you do it?

Thank you very much :)
David

Got Unable to find template "BreithbarbotCropperBundle:Form:fields.html.twig" on Symfony4

Hello

Thanks for the bundle, however when I try to use it in my symfony4 project I got the error

Unable to find template "BreithbarbotCropperBundle:Form:fields.html.twig" (looked into: /var/www/symfony4/templates, /var/www/symfony4/vendor/symfony/twig-bridge/Resources/views/Form).

and the traceback point my {{ form_start(form) }}

I try removing the line all together and now i got the error at

{% include 'BreithbarbotCropperBundle:Form:cropper_modal.html.twig' with {'mapping': 'user_avatar'} %}

for this one it seems to be because it needs to be rewritten in symfony4 like this

{% include '@BreithbarbotCropper/Form/cropper_modal.html.twig' with {'mapping': 'user_avatar'} %}

can't install on php 8

composer expect php7.4, is ithere a good raison why it don't accept php 8 ? what about an update ?

$(...).cropper is not a function

Hello, i'm trying to use your bundle. I followed the tutorial but when i upload an image i got the following error :

ajouter:250 Uncaught TypeError: $(...).cropper is not a function
at FileReader.reader.onload (ajouter:250)

Thanks

EDIT : I had to include the link to cropper.js in my file too

Undefined index: data_class

Hello,
I followed the seven steps in documentation and I have this error when I clear the cache with console.
php bin/console cache:clear --no-warmup

array:2 [
  "config" => array:1 [
    "default_folder" => "uploads"
  ]
  "mappings" => []
]

In BreithbarbotCropperExtension.php line 36:
                                       
  Notice: Undefined index: data_class

I tried different solutions and with the example.
The symfony version is 3.4.17.

Thanks you !

breithbarbot/cropper v2.1.2 conflicts with symfony/symfony[v3.4.33]

Hi there.
Not sure what I'm doing wrong but it seems as if breithbarbot/cropper conflicts with symfony/symfony. I'm getting this:

$ composer req breithbarbot/cropper
Using version ^2.1 for breithbarbot/cropper
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Conclusion: remove symfony/symfony v3.4.33
- Conclusion: don't install symfony/symfony v3.4.33
- breithbarbot/cropper v2.1.0 conflicts with symfony/symfony[v3.4.33].
- breithbarbot/cropper v2.1.1 conflicts with symfony/symfony[v3.4.33].
- breithbarbot/cropper v2.1.2 conflicts with symfony/symfony[v3.4.33].
- Installation request for symfony/symfony (locked at v3.4.33, required as ^3.4) -> satisfiable by symfony/symfony[v3.4.33].
- Installation request for breithbarbot/cropper ^2.1 -> satisfiable by breithbarbot/cropper[v2.1.0, v2.1.1, v2.1.2].

Installation failed, reverting ./composer.json to its original content.

Multiple usage settings does not work

Hello and thank for your very usefull bundle :)

From Symfony 5, I installed and configured your bundle. All works like a charm when I use only one BreithbarbotCropperType field in a form. But when I want use two BreithbarbotCropperType fields in a same form I get a weird front bug :

  • On my website, I go to the 'new' page of my entity (an article)
  • The two BreithbarbotCropper fields are showed [1]
  • But, when I click on the second field [2] (the Main image Field), two 'Cropping tool' popins appears (instead one) [3].
  • The first 'Cropping tool' popin does not work (click on the image area have not any effect and there isn't any error in the javascript console) [4]
  • The first 'Cropping tool' popin does not work, so I close it and I can use the second '' popin [5]
  • Click on the image area of the second popin works well (I can choose an image and crop it). [6]
  • But when I click on the 'Save' button, the second field of my form keeps empty. The first field 'Teaser Image' has been used instead [7]

Of course I followed the 'Multiple usage instructions' page here https://github.com/breithbarbot/cropper-bundle/blob/master/Resources/doc/usage_multiple.md

My code :

The config/packages/breithbarbot_cropper.yaml file :

breithbarbot_cropper:
mappings:

  article_teaserImage:
    routes:
      path_add: 'admin_cropper_article_teaserImage'
    ratio:  '16/9'

  article_mainImage:
    routes:
      path_add: 'admin_cropper_article_mainImage'
    ratio:  '82/25'

The src/Form/ArticleType,php file :

    $editT = (null !== $builder->getData()->getTeaserImage());
    $editM = (null !== $builder->getData()->getMainImage());

    $builder
        ->add('teaserImage', BreithbarbotCropperType::class, [
            'mapped' => $editT,
            'mapping' => 'article_teaserImage',
            'additional_data' => [
                'entity_id' => $builder->getData()->getId(), // Get current ID
            ],
            'identifier' => 'crop1',
        ])
        ->add('mainImage', BreithbarbotCropperType::class, [
            'mapped' => $editM,
            'mapping' => 'article_mainImage',
            'additional_data' => [
                'entity_id' => $builder->getData()->getId(), // Get current ID
            ],
            'identifier' => 'crop2',
        ])

And the twig template file :

{% include '@BreithbarbotCropper/Form/cropper_modal.html.twig' with {'mapping': 'article_teaserImage','id': 'crop1'} %}
{% include '@BreithbarbotCropper/Form/cropper_modal.html.twig' with {'mapping': 'article_mainImage','id': 'crop2'} %}

{#{{ include('article/_form.html.twig') }}#} {# commented for debugging #}
{{ form_row(form.teaserImage) }}
{{ form_row(form.mainImage) }}

=> In the twig template file, if I comment {{ form_row(form.mainImage) }} the {{ form_row(form.teaserImage) }} works perfectly.
=> And vice versa, if I comment {{ form_row(form.teaserImage) }} the {{ form_row(form.mainImage) }} works perfectly

And finally, the code of the page

f12

Did I make a mistake somewhere ? Did I find a bundle bug ?
Thanks for your help :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.