Skip to content
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

More fine-grained crop options #10

Closed
E-VANCE opened this issue Oct 8, 2020 · 4 comments
Closed

More fine-grained crop options #10

E-VANCE opened this issue Oct 8, 2020 · 4 comments

Comments

@E-VANCE
Copy link

E-VANCE commented Oct 8, 2020

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

@Twansparant
Copy link
Contributor

Twansparant commented Oct 8, 2020

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!

@E-VANCE
Copy link
Author

E-VANCE commented Oct 12, 2020

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!

@Elwood-P
Copy link

Elwood-P commented Feb 9, 2021

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.

@Twansparant
Copy link
Contributor

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants