clarifynl/responsive-pics

More fine-grained crop options

Closed this issue · 4 comments

Hey there,

I am working on a blog format atm and I am having trouble adjusting the crop / focal point to cater for the different images present... This mainly concerns the vertical crop position, I can choose between top or center here but I would love to have more fine grained control.

Maybe one could use additional percentage values to kinda specify a 'padding'?

Like breakpoint:width [/factor|height]|c t10 which would translate as

  • crop center horizontally
  • crop top minus 10% vertically

so we end up with a cropped image where the vertical crop isn't glued to the top border...?

Any thoughts?

Thanks & regards,
Henning

Hi @E-VANCE,

So if understand correctly you would want to add 10% white space to the vertical crop?
Or do you want the vertical crop to start at 10% of the top?

In both cases, this is not supported yet unfortunately...
At the moment, we're using the $wp_editor->resize function for cropping where $crop is an array with the crop positions:

[
  [0] => 'left',
  [1] => 'center'
]

In order to get more control over the crop positions, we should switch to the $wp_editor->crop function, then we can start using these crop parameters:

$src_x
$src_y

In order to use percentages we should convert this to pixels beforehand.
Feel free to open a PR, but I will add this to the todo list!

Thanks!

Hey @Twansparant,

Or do you want the vertical crop to start at 10% of the top?

That's the one.

Thanks for the explanation & I'll look into it creating a PR!

I'm not sure this is will be a useful option. Any focal point choice is more useful to be set per image (either manually say using a GUI in the media library, or automatically via some smart crop algorithm). Crop settings in a template to be applied arbitrarily to all images doesn't seem that useful.

I added support for setting crop positions as percentages: /0.75|75 50 in the latest 1.4.0 release.
I hope this will give you some more fine-grained options!