PHPackages                             willmorgan/silverstripe-cropperfield - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. willmorgan/silverstripe-cropperfield

AbandonedArchivedSilverstripe-module[Image &amp; Media](/categories/media)

willmorgan/silverstripe-cropperfield
====================================

Provides an interface for you to generate thumbnails of things in the CMS. Adapters can be used to extend the functionality to thumbnail videos, PDF documents, etc.

2.0.0(9y ago)294.3k5[1 PRs](https://github.com/willmorgan/silverstripe-cropperfield/pulls)BSD-3-ClauseJavaScriptPHP &gt;=5.3

Since Dec 17Pushed 5y ago6 watchersCompare

[ Source](https://github.com/willmorgan/silverstripe-cropperfield)[ Packagist](https://packagist.org/packages/willmorgan/silverstripe-cropperfield)[ RSS](/packages/willmorgan-silverstripe-cropperfield/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (4)Used By (0)

SilverStripe CropperField
=========================

[](#silverstripe-cropperfield)

[![Build Status](https://camo.githubusercontent.com/1128aed497b167b4a833e46df1f2f16bd65552a5983afc9243d2e463a9b0bd23/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f77696c6c6d6f7267616e2f73696c7665727374726970652d63726f707065726669656c642e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/willmorgan/silverstripe-cropperfield)

Do you need to crop your images for art direction purposes?

Perhaps this is for responsive design, or perhaps you're tired of `CroppedResize`, `PaddedResize`, `Square` and general centre-based resizing functionality in SilverStripe that doesn't quite meet your image cropping needs.

Maybe `CropperField` is for you. Whilst it's called `CropperField`, that's just the user interface. Behind the scenes, a clean and extensible architecture allows you to crop almost anything - external URLs, documents, video frames, etc..

For the field itself, the frontend is powered by [Cropper v0.7.5](https://github.com/fengyuanchen/cropper) by Fengyuan Chen.

**Warning: Under development / alpha. Do not use unless you are prepared to contribute!**

### Installation

[](#installation)

1. `composer require willmorgan/silverstripe-cropperfield`
2. Specify a version constraint.

- While this module is in heavy development, you probably want to use `~0.X` or similar.

### Screenshot

[](#screenshot)

The field currently looks like this in a CMS setting.

[![Screenshot of the field](docs/images/screenshot.png)](docs/images/screenshot.png)

### Usage

[](#usage)

1. Specify a `$has_one` `Image` relationship on the object that should own the cropped image.
2. Specify an image based `UploadField` whose image you wish to crop.

- Only `UploadField` is supported right now. Non-images will break. Sorry.

2. Create an `AdapterInterface` implementor to pass into your `CropperField`

- See \[1\]; the adapters are generic enough for you to supply anything - as long as there's a `File`object backing it (regardless of whether it exists).

3. Set some options, if you so desire.
4. Happy cropping.

#### Example

[](#example)

In this example, a configuration like this has been set up:

```
$has_one = array(
	'MyBigPhoto' => 'Image',
	'MyArtDirectionCrop' => 'Image',
);
```

Inside a `getCMSFields` call, or similar:

```
$uploadField = new UploadField('MyBigPhoto', 'Big Photo Uploader');
$cropperField = new CropperField\CropperField(
	'MyArtDirectionCrop',
	'Cropped Image',
	new CropperField\Adapter\UploadField(
		$uploadField
	)
);
```

You can now use `$MyArtDirectionCrop` in your template as you would any other image (i.e. you can use `$ResizeRatio`, `$Square`, etc.)

The initial benefit is the CMS user gets to specify the true focus point of a potentially high resolution image, and you / your frontend team can reuse that base cropped image responsively, be it using `srcset`, `picture + source`, etc.

#### Options

[](#options)

You can set these options on the CropperField to get some control over your CMS users' actions.

Option nameValue exampleDefault valueDescription`aspect_ratio``null` or positive float, like `16/9``null`The aspect ratio you want generated cropped images to have.`crop_min_width`Positive integer, like `256``256`The minimum dimensions a crop can be, in px.`crop_min_height`Positive integer, like `256``256``crop_max_width``null` or positive integer`null`Maximum dimensions a crop can be, in px.
Blank by default because this restricts the art direction somewhat. If you wish to limit the actual generated size of the cropped image, set `generated_max_*` instead.`crop_max_height``null` or positive integer`null``generated_max_width`Positive integer, like `512``512`The maximum dimensions a generated image can be, in px.
If the crop is above this, then it will be downscaled according to the declared aspect ratio, or the implied aspect ratio if one is not specified.`generated_max_height`Positive integer, like `512``512`#### Supplied Adapters

[](#supplied-adapters)

- `CropperField\Adapter\UploadField` for image based upload fields

#### Supplied Croppers

[](#supplied-croppers)

- `CropperField\Cropper\GD` for GD installations
- Imagick coming soon

#### Customisation

[](#customisation)

- Templates: you can easily customise the template used - just override `CropperField.ss`
- You can write your own croppers (say, for `Imagick`).
    1. Implement the `CropperInterface`
    2. Either set it on a per-instance basis using `CropperField->setCropper()`
    3. Set it in YML, overriding `CropperFactory.cropper`. The factory uses `Injector` for DI.

### Compatibility

[](#compatibility)

- While Cropper is able to support browsers as old as IE8, the `CropperField` CMS UI has been tested only in Chrome.

### Similar modules

[](#similar-modules)

If this doesn't look right for you\*, check out some alternatives:

- [@jonom has built silverstripe-focuspoint](https://github.com/jonom/silverstripe-focuspoint), which is powered by his popular [jQuery FocusPoint library](https://github.com/jonom/jquery-focuspoint)

*\* As a sidenote, I'd appreciate you taking the time to let me know why*

### Licensing

[](#licensing)

- SilverStripe CropperField is released under the BSD License; however, please note:
- [Cropper v0.7.5](https://github.com/fengyuanchen/cropper) is released under the MIT license.

### Built by

[](#built-by)

[Will Morgan](http://willmorgan.co.uk), who is available for hire.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 53.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~381 days

Total

3

Last Release

3399d ago

Major Versions

0.6.x-dev → 2.0.02017-01-17

### Community

Maintainers

![](https://www.gravatar.com/avatar/48f9368074adbcb9b0ebd892c5b1c2714ce4b05fe210a7e3beed23ca6e382407?d=identicon)[willmorgan](/maintainers/willmorgan)

---

Top Contributors

[![willmorgan](https://avatars.githubusercontent.com/u/168688?v=4)](https://github.com/willmorgan "willmorgan (7 commits)")[![dhensby](https://avatars.githubusercontent.com/u/563596?v=4)](https://github.com/dhensby "dhensby (4 commits)")[![muskie9](https://avatars.githubusercontent.com/u/870751?v=4)](https://github.com/muskie9 "muskie9 (2 commits)")

---

Tags

thumbnailsilverstripecrop

### Embed Badge

![Health badge](/badges/willmorgan-silverstripe-cropperfield/health.svg)

```
[![Health](https://phpackages.com/badges/willmorgan-silverstripe-cropperfield/health.svg)](https://phpackages.com/packages/willmorgan-silverstripe-cropperfield)
```

###  Alternatives

[sybio/image-workshop

Powerful PHP class using GD library to work easily with images including layer notion (like Photoshop or GIMP)

860918.1k11](/packages/sybio-image-workshop)[jonom/focuspoint

Smarter automatic image cropping for Silverstripe

108645.6k49](/packages/jonom-focuspoint)[jbzoo/image

A PHP class that simplifies working with images

171126.9k3](/packages/jbzoo-image)[stefangabos/zebra_image

A single-file, lightweight PHP library designed for efficient image manipulation featuring methods for modifying images and applying filters

141110.4k6](/packages/stefangabos-zebra-image)[sadovojav/yii2-image-thumbnail

Yii2 image thumbnail component

2142.1k](/packages/sadovojav-yii2-image-thumbnail)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
