You should be able to automatically enable smartcrop with the following code, added to your functions.php:
add_filter( 'wp_generate_attachment_metadata', array( $this, function( $metadata, $post_id ) {
update_post_meta( $post_id, '_wpsmartcrop_enabled', true );
} ), 20, 2 );
Thank you very much for quick answer, but this filter falis image uplod (
I’m sorry, I missed a line in the code snippet. Try this:
add_filter( 'wp_generate_attachment_metadata', array( $this, function( $metadata, $post_id ) {
update_post_meta( $post_id, '_wpsmartcrop_enabled', true );
return $metadata;
} ), 20, 2 );
Sorry, but it still fails image uploads. Thank you anyway!)
clearly I should stop trying to write code at three am… that was two different typos in two different snippets.
Try this:
add_filter( 'wp_generate_attachment_metadata', "smartcrop_enable_by_default", 20, 2 );
function smartcrop_enable_by_default( $metadata, $post_id ) {
update_post_meta( $post_id, '_wpsmartcrop_enabled', true );
return $metadata;
}
It works! Horay! Sucess! Thanks a lot! )