Salted Herring's Cropper Field for SilverStripe. This is to avoid the deadly issue that FileSync task will disconnect all cropped images, when using silverstripe-cropperfield. Please remove silverstripe-cropperfield module if you have already installed it, other it will result in funny conflict.
This doc is for 1.0 and above. If you are using 1.0- versions, do not use this doc.
- Download it to SilverStripe's root directory
git clone [email protected]:salted-herring/salted-cropper.git
or
composer require salted-herring/salted-cropper
- Sake it
sake dev/build
-
flush frontend and backend's cache
-
Sample code:
protected static $has_one = array( 'Photo' => 'Image' ); public function getCMSFields() { $fields = parent::getCMSFields(); ... $fields->addFieldTotTab(TAB_NAME, SaltedUploader::create('Photo', A_TITLE_TO_THE_FILED)->setCropperRatio(16/9)); ... return $fields; }
-
Upload and image, and then click the edit button - in the drop down area, you will see the cropper area. Do the cropping and then save the image (NOTE: if you don't save the image editing, before you save the page/data object, it will not take effect)
-
Output
$Photo $Photo.Cropped $Photo.Cropped.SetWidth(100)