Support » Plugin: WP SmartCrop » Is it possible to make checkbox Enable Smart Cropping checked by default

  • 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)
  • 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 );
    redchinesepanda

    (@redchinesepanda)

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

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

    (@redchinesepanda)

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

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

    (@redchinesepanda)

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

    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.