• Resolved redchinesepanda

    (@redchinesepanda)


    Hello! ) Thank you very much for sooo nice plugin. CI need a little help. Tell me please is it possible to make checkbox Enable Smart Cropping checked by default?
    Thanks in advance

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor gschoppe

    (@gschoppe)

    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 );
    Thread Starter redchinesepanda

    (@redchinesepanda)

    Thank you very much for quick answer, but this filter falis image uplod (

    Plugin Contributor gschoppe

    (@gschoppe)

    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 );
    
    Thread Starter redchinesepanda

    (@redchinesepanda)

    Sorry, but it still fails image uploads. Thank you anyway!)

    Plugin Contributor gschoppe

    (@gschoppe)

    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;
    }
    
    Thread Starter redchinesepanda

    (@redchinesepanda)

    It works! Horay! Sucess! Thanks a lot! )

    Thread Starter redchinesepanda

    (@redchinesepanda)

    Thank you very muxh! )

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Is it possible to make checkbox Enable Smart Cropping checked by default’ is closed to new replies.