nlybe/cropper

This package is abandoned and no longer maintained. No replacement package was suggested.

Cropper jQuery image cropping tool for Elgg

2.1.3 2016-12-20 01:38 UTC

This package is auto-updated.

Last update: 2023-04-17 09:54:14 UTC


README

Elgg 2.1+

Responsive image cropping tool for Elgg, based on jQuery and integrating the JS library Cropper.

Cropper plugin replace the default core Elgg profile avatar cropping tool.

Features

  • Supports touch (mobile)
  • Supports to crop on a canvas
  • Responsive
  • Option to add cropper as a form input
  • Option to select size of preview box in settings
  • Plenty of Cropper tool options available on plugin settings
  • Aspectratio cropper option can be passed as param in cropper input, overriding the value plugin settings

How to Use

1. Replace core Elgg profile avatar cropping tool

If plugin is enabled, the default core Elgg profile avatar cropping tool is replaced by this image cropping tool. Several options in plugin settings can be used for customizing the tool.

2. Use cropper input in any form

The cropper input can be used in any Elgg form, passing just the image to crop and optionally the Aspectratio (overriding the value plugin settings):

// assign photo to cropper input
$master_img = elgg_view('output/img', array(
    'src' => $vars['entity']->getIconUrl('master'),
    'alt' => elgg_echo('avatar'),
    'class' => 'mrl',
    'id' => 'image',
));
$vars['image_to_crop'] = $master_img;

// optionally assign custom aspectratio to overide the aspectratio in settings
// set blank for free ratio or enter number e.g. 1 for 1/1
// if put comment the following line, the aspectratio value from settings will be used
$vars['aspectratio'] = 1;

echo elgg_view_input('cropper', $vars);