• Stars
    star
    106
  • Rank 325,871 (Top 7 %)
  • Language
    PHP
  • License
    GNU General Publi...
  • Created almost 7 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Image Aspect Ratio Crop field for Advanced Custom Fields

ACF Image Aspect Ratio Crop Field

GitHub Workflow Status GitHub Workflow Status WordPress plugin Active installs WordPress Plugin Rating WordPress Plugin Required PHP Version WordPress Plugin: Required WP Version WordPress Plugin: Tested WP Version codecov Active Development

A field for Advanced Custom Fields that forces the user to crop their image to specific aspect ratio or pixel size after uploading. Using an aspect ratio is especially useful in responsive image use cases.

After cropping, a new cropped image variant is created in the gallery and saved into the post. Thumbnails are also generated for the new image. User can re-crop the original image at any time from the post page.

The cropped image variants are hidden by default in the media browser and on the media page but you can view them by selecting the "list view" on the media page.

Modes of operation

There are three modes of operation: aspect ratio, pixel size and free crop. You can select this option when creating the field in ACF field options.

Aspect ratio

Use this option if you want the image to be of specific aspect ratio like 16:9 but the pixel size is not important.

After selecting an image, user can select an area from the image that matches this aspect ratio. When crop button is pressed, the area is cropped from the original image.

If you need a smaller image size, you make use of WordPress's thumbnail functionality to access a smaller version of the image.

Pixel size

Use this option if you need a specific pixel size image like 640x480. User will not be able to select an image smaller than the defined pixel size.

After selecting an image, user can select an area from the image they want, which can be larger than the pixel size but may not be smaller. The aspect ratio of the selection is locked according to the pixel size.

When crop button is pressed, the area is cropped from the original image. After the crop is complete, the image will be automatically scaled down to the pixel size. This means the final image will always be the specified size.

Free crop

Crop can be done freely, there are no aspect ratio limitations.

Screenshots

Cropping an image to 16:9 aspect ratio

Screenshot of cropping an image

Cropping in progress

Screenshot of cropping in progress

Option to re-crop the image after upload

Screenshot of the image field

Download

You can download the plugin from the WordPress plugin directory, or download the latest release as a zip file from GitHub releases.

Requirements

  • WordPress 4.9 or later
  • PHP 5.6 or later
  • Advanced Custom Fields 5.8 or later (Pro or Free)

Compatiblity

  • Polylang Pro
  • Enable Media Replace
  • WP Offload Media, Media Cloud and other plugins that move media files to remote location

Frequently Asked Questions

Can I use this plugin with a front-end acf_form?

Yes, this functionality has been added in version 5.0.0. Please test it and give feedback if you encounter any issues.

Can I access metadata in the original image from a cropped image?

Yes, the original image data is saved under original_image key in the returned ACF array. You can access data such as alt text, description and title this way.

Can I use this plugin with Elementor?

No, not really. Elementor only supports built-in ACF fields. Please contact Elementor support and ask them to add support for 3rd party fields. For some workarounds for limited Elementor support, see this post.

Can I use this plugin with Beaver Builder?

No, not really. Beaver Builder only supports built-in ACF fields. Please contact Beaver Builder support and ask them to add support for 3rd party fields. However, there is a work around this limitation by using a plugin called "Toolbox For Beaver Builder". Please see their website for more details.

How is this different from the other plugin?

This plugin is similar to Advanced Custom Fields: Image Crop Add-on. I originally created a fork of that plugin to add functionality I need: specifying an aspect ratio instead of pixel size. Unfortunately the plugin doesn't seem to be maintained anymore so my pull request was not merged.

So I created ACF Image Aspect Ratio Crop from scratch as an alternative to ACF Image Crop.

Possibility to use a pixel size instead of aspect ratio was added later on because I got so many requests for adding that feature.

The other plugin is not actively maintained and does not work well with latest ACF versions. I try to maintain this plugin as best as I can when new versions of ACF and WordPress come out.

Thanks

Special thanks to Anders Thorborg for ACF Image Crop which served as a inspiration for this plugin. Also, thanks to Fengyuan Chen for the cropper.js library!

License

GPL v2 or later

More Repositories

1

timber-starter-theme-webpack

The "_s" for Timber: a dead-simple theme that you can build from. Now with Webpack!
PHP
42
star
2

large-small-dynamic-viewport-units-polyfill

Polyfill for svh, dvh and lvh CSS viewport units
HTML
41
star
3

nice-nginx-error-page

What if your application could look nice even when it's crashing?
CSS
21
star
4

disable-media-pages

WordPress plugin to disable "attachment" pages automatically created for WordPress media
PHP
19
star
5

EloquentMigrationsUsingPhinx

An example how to create Eloquent migrations using Phinx
PHP
16
star
6

jpeg-xl-encode

A PHP library for encoding JPEG XL images. Very much inspired by WebP Convert.
PHP
16
star
7

syllable-hyphenator

Server-side hyphenation for WordPress with Syllable library.
PHP
12
star
8

disable-drop-cap

Plugin to disable drop cap in Gutenberg editor paragraph block.
PHP
11
star
9

acf-commonmark

Allows you to add a Markdown field to ACF using CommonMark standard
SCSS
8
star
10

disable-drop-cap-v2

A plugin to disable the drop cap option in Gutenberg editor paragraph block. This is version 2.
PHP
4
star
11

compare-app-webp-500

Comparing cjpeg, MozJPEG, WebP and AVIF compression at the same SSIM.
JavaScript
3
star
12

wordpress-on-do-apps-demo

WordPress on DigitalOcean App Platform demo
PHP
3
star
13

relevanssi-finnish-base-forms

Relevanssi plugin to add Finnish base forms in search index
PHP
2
star
14

Dullahan

Headless PHP CMS
JavaScript
2
star
15

TikoPizza3

Java
1
star
16

jpeg-xl-static

UNOFFICIAL static build of cjxl and djxl tools for Linux and Windows
C++
1
star
17

compare-app-webp-1500

Comparing cjpeg, MozJPEG, WebP and AVIF compression at the same SSIM.
JavaScript
1
star
18

images-guide-mirror

Mirror of the recently taken down "Essential Image Optimization" guide by Addy Osmani
HTML
1
star
19

acf-image-aspect-ratio-crop-packagist-release

This is a repository to push compiled front-end assets to Packagist, please use https://github.com/joppuyo/acf-image-aspect-ratio-crop instead
PHP
1
star
20

imagemagick-extended

This plugin adds some extra options for WordPress ImageMagick editor
PHP
1
star