variable crop option with add_image_size()


In my child Theme I have set my custom image with add_image_size( 'big', 1500, 1000 )
I left out the crop parameter, but it is [false by default][1] anyway.

I want to make this a variable option.

I have just written a plugin that displays all the registered image sizes (including WP’s thumbnail, medium and large sizes) plus my custom size.

With checkboxes I do update_option($_size."_crop", true) for WP’s image sizes and global $_wp_additional_image_sizes; $_wp_additional_image_sizes[$_size]['crop'] = true for my custom size.

The thumbnail, medium and large work all fine but I can’t get to override the default false $crop parameter from add_image_size?
When I var_dump($_wp_additional_image_sizes;) on my plugin page the boolean displays true, but when I upload a new image it is like add_image_size() wins over my plugin?

When I set add_image_size( 'big', 1500, 1000, true) in functions.php everything works like I want, but I want to make it an option to switch between hard and soft cropping – from my plugin options page obviously.

, FFish 9 years 2015-05-20T12:42:34-05:00 0 Answers 95 views 0

Leave an answer