Skip to content

Enabled cropping images around selected focal point; #4850 #991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 7.dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion docs/fieldtypes/file.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,25 @@ Resize the image.

### `:crop`

{news_image:crop width="100" height="100" position="center"}
{news_image:crop width="100" height="100" position="focal"}

Crop the image. By default, cropping uses top left corner of image as starting position. You can specify `x` and `y` offset, if needed, or `position="center"` parameter to make crop happen close to image center.

If you specify `position="focal"` the cropping will be done close to the focal point of the image as set in the Control Panel.

You can also specify numeric values for position, separated by a pipeline, e.g. `position="0.2|0.2"`. The numbers are between `0` and `1`, where `0` is the left/top edge of the image and `1` is the right/bottom edge of the image. The first number is for the x-axis, the second for the y-axis.
The numbers are relative to the image size, so `0.5|0.5` would be the center of the image.

You also can use words instead of numbers, e.g. `position="left|top"` or `position="right|bottom"`.

| Parameter | Values | Default | Description |
| --------- | ------- | ---------- | -------------------------------------- |
| width | `Number` | `*required`| Width to crop to |
| height | `Number` | `*required`| Height to crop to |
| quality | `0`-`100`| `75` | Image quality, % |
| maintain_ratio | `y` / `n` | `y`| Keep image ratio (yes/no) |
| position | `center` | | Crop close to image center |
| position | `focal` | | Crop close to image focal point as set in CP |
| x | `Number` | `0` | Horizontal offset, px |
| y | `Number` | `0` | Vertical offset, px |

Expand Down