junaidbhura / fly-dynamic-image-resizer

Fly Dynamic Image Resizer plugin for WordPress
https://wordpress.org/plugins/fly-dynamic-image-resizer/
MIT License
162 stars 26 forks source link

Crop by coordinates (enhancement) #49

Closed mupic closed 3 years ago

mupic commented 3 years ago

Checklist:

Description

Added the ability to select the cropping area in percent or in pixels.

Added new argument types for the crop attribute:

$position = array('right', 'bottom'); //Normal use

$position = array(100, 300, 960, 1280); // Coordinates are relative to the original size. ($x, $y, $custom_crop_width, $custoim_crop_height) - $customcrop* is a value for custom selection of the cropped area relative to the original image size. If one value is filled in and the other value is left blank or 0 is specified, then the value will be replaced with the original image size. It should be borne in mind that the size of the cropping area should not exceed the size of the picture, otherwise the picture will be smaller than expected, l.e. this statement must be true: $x + $custom_crop_width <= $original_width

$position = array((float) 1, (float) 1); // Floating point numbers are calculated as percentages, relative to their original size. This example is equivalent to array('right', 'bottom')

$position = array((float) 0.6, (float) 0.5, 960, 1280); //Cuts out an area of 960x1280 from the center with a slight shift to the right.

echo fly_get_attachment_image(get_post_thumbnail_id(), array(480, 640), $position); //The returned image size will be 480x640.

How has this been tested?

I did not understand testing through a special testing program, I just checked on my project that all the entered data with different pictures work correctly.

Types of changes

New feature (non-breaking change which adds functionality)

junaidbhura commented 3 years ago

Hi @mupic thanks for all the effort creating this Pull Request. As discussed in #48 , I think this functionality may not be a good fit for this plugin.

But your code may be useful for others looking for similar functionality. Please feel free to create issues in the future, but as mentioned in the Contributing page lets first agree on a solution before creating a Pull Request.

Thanks again!

kubiqsk commented 1 year ago

Hi @mupic , you can try this plugin instead https://wordpress.org/plugins/better-image-sizes/ It's inspired by fly-dynamic-image-resizer and it offers more functionalities including focal point picker in media library