cita / image-cropper
CitaNZ's image cropper for SilverStripe 4
Installs: 413
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 2
Open Issues: 10
Language:JavaScript
Type:silverstripe-vendormodule
Requires
- silverstripe/framework: ^4.0
- dev-master
- 2.0.3
- 1.0.0
- dev-dependabot/npm_and_yarn/client/js/cropperjs/json5-1.0.2
- dev-dependabot/npm_and_yarn/client/js/cropperjs/qs-and-body-parser-6.11.0
- dev-dependabot/npm_and_yarn/client/js/cropperjs/decode-uri-component-0.2.2
- dev-dependabot/npm_and_yarn/client/js/cropperjs/shell-quote-1.7.3
- dev-dependabot/npm_and_yarn/client/js/cropperjs/minimist-1.2.6
- dev-dependabot/npm_and_yarn/client/js/cropperjs/karma-6.3.16
- dev-dependabot/npm_and_yarn/client/js/cropperjs/follow-redirects-1.14.8
- dev-dependabot/npm_and_yarn/client/js/cropperjs/engine.io-4.1.2
- dev-dependabot/npm_and_yarn/client/js/cropperjs/log4js-6.4.0
- dev-develop
- dev-dependabot/npm_and_yarn/client/js/cropperjs/nth-check-2.0.1
This package is auto-updated.
Last update: 2024-12-05 14:09:11 UTC
README
It's a continious development of Salted Herring's Cropper Field for SilverStripe - 4 (https://github.com/salted-herring/salted-cropper)
Usage
- Install
composer require cita/image-cropper
-
/dev/build?flush=all
-
Sample code:
... use Cita\ImageCropper\Model\CitaCroppableImage; use Cita\ImageCropper\Fields\CroppableImageField; ... private static $has_one = array( 'Photo' => CitaCroppableImage::class ); public function getCMSFields() { $fields = parent::getCMSFields(); ... // adding a free cropper $fields->addFieldToTab(TAB_NAME, CroppableImageField::create('PhotoID', A_TITLE_TO_THE_FILED)); // adding cropper with ratio $fields->addFieldToTab(TAB_NAME, CroppableImageField::create('PhotoID', A_TITLE_TO_THE_FILED)->setCropperRatio(16/9)); ... return $fields; }
-
Add image > upload/select > save > edit > do your cropping > save
-
Output
$Photo $Photo.Cropped $Photo.Cropped.SetWidth(100)
AWS support
If you are using SS's S3 assets module to store your images, you may also want to add this into your site's config yaml
SilverStripe\Admin\LeftAndMain:
extra_requirements_javascript:
- 'resources/vendor/cita/image-cropper/client/js/s3-workaround.js'