0

I've been working on a custom theme using the blankslate boilerplate & I'm happy with how it performs with a few minor details. This one concerns image cropping when a site uses the Offload Media plugin & has the remove files from server setting enabled. I've spoken with the OM folks a bit & they're helpful but at the end of the day if their plugin isn't causing any problems they're not there to troubleshoot my theme, which I understand.

My question is how can I modify my code to delay sending the file to the S3 bucket until the customizer has had a chance to crop & place the image?

My code is below & I appreciate any advice!

    // Some picture
        $wp_customize->add_setting( 'some_setting',
        array(
            'default' => '',
            'sanitize_callback' => 'esc_attr',
        )
        );

        $wp_customize->add_section('some_section', array(
            'title' => __('Some Picture', 'textdomain'),
            'priority' => 10,
            'sanitize_callback' => 'esc_attr',
        ));

        $wp_customize->add_control( new WP_Customize_Cropped_Image_Control( $wp_customize, 'some_setting', array(
            'label'    => __( 'Some Picture', 'textdomain' ),
            'section' => 'title_tagline',
            'height'      => 250,
            'width'       => 250,
            'flex-width'  => false,
            'flex-height' => false,
            'settings' => 'some_setting',
            'transport' => 'refresh'

        ) ) );

2
  • It was actually painfully simple to fix this, I needed to change WP_Customize_Cropped_Image_Control to WP_Customize_Media_Control, add in the mime type, & define the thumbnail to call. Many thanks to OM's own Ian for providing guidance!
    – Jeff W
    Commented May 12, 2020 at 18:21
  • You could formulate this into an answer and accept it for future reader ;)
    – Howdy_McGee
    Commented May 12, 2020 at 19:03

1 Answer 1

0

Aye, it's best if I adhere to policies - as I mentioned in my comment, the fix was painfully obvious updating the provided code to the following & then calling for set image sizes, even if I then had to first define the image sizes, resolved the issue:

// Some picture
        $wp_customize->add_setting( 'some_setting',
        array(
            'default' => '',
            'sanitize_callback' => 'esc_attr',
        )
        );

        $wp_customize->add_section('some_section', array(
            'title' => __('Some Picture', 'textdomain'),
            'priority' => 10,
            'sanitize_callback' => 'esc_attr',
        ));

        $wp_customize->add_control( new WP_Customize_Media_Control( $wp_customize, 'some_setting', array(
            'label'    => __( 'Some Picture', 'textdomain' ),
            'section' => 'title_tagline',
            'height'      => 250,
            'width'       => 250,
            'flex-width'  => false,
            'flex-height' => false,
            'settings' => 'some_setting',
            'mime_type' => 'image',
            'transport' => 'refresh'

        ) ) );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.