Code Monkey home page Code Monkey logo

ca.bidon.imagecrop's Introduction

CiviCRM image crop extension

The extension integrates Jcrop with CiviCRM.
https://lab.civicrm.org/extensions/imagecrop

It allows to crop and scale image fields in CiviCRM. For now, it works only with the Contact "image_URL" field in contact records view/edit and profile view/edit.

More information about Jcrop can be found here: http://deepliquid.com/content/Jcrop_Download.html

Installation

  • Enable this extension in CiviCRM (Administer > System > Extensions)

The Jcrop library is bundled in this extension.

Technical details

When cropping, the extension sends an ajax request to the server with the contact ID and a set of coordinates for the cropping.

A new image is saved in a "imagecrop" subdirectory of customFileUploadDir (ex: files/civicrm/custom/imagecrop). The directory is created if necessary.

The original image is always kept, to reduce the risks in case of mistake. The image is swapped when viewing the contact record (in hook_civicrm_pageRun).

Since CiviCRM 4.4.5, since we cannot serve images directly from the 'upload' directory, this extension implements a Page handler on /civicrm/imagecrop/imagefile to serve the cropped image from the 'upload' subdirectory where cropped images are stored.

Contributors

Copyright

Copyright (C) 2013-2017 Mathieu Lutfy ([email protected])
Copyright (C) 2013-2017 Luciano Spiegel ([email protected])

License: AGPL 3, see LICENSE.txt for details.

Jcrop is free software under MIT License. Copyright (c) 2008-2012 Tapmodo Interactive LLC https://github.com/tapmodo/Jcrop

ca.bidon.imagecrop's People

Contributors

mlutfy avatar rubofvil avatar sluc23 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

sluc23 ixiam

ca.bidon.imagecrop's Issues

Better UI for opening the jcrop popup

There should be a better UI for opening the jcrop popup.

Currently the user has to click on the image of the contact record. We should probably show a "crop" link under the image instead.

Support CiviCRM 4.4 to 4.6

Since ~ CiviCRM 4.4.5, the uploads directory is not directly accessible. This causes a number of issues with the extension.

Do not load jcrop if the CMS already loads it

Avoid bloating the js payload by not loading the jcrop js if the CMS (drupal/wordpress) has already loaded it.

For Drupal, the imagefield_crop module seems to only load the jcrop JS when necessary, so I don't think much can be done there.

For Wordpress, according to Hershel, jcrop ships with core, but still need to check whether it is always loaded.

Alternatively, we could just add a setting in the preferences, and we can test there whether Jcrop was already loaded.

Check permissions

Check if the user has access to edit the user, before allowing to crop the image (both when showing the crop link, and in the ajax call).

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.