Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#33357 closed defect (bug) (invalid)

Customizer: Error with cropped-image control

Reported by: pekz0r's profile pekz0r Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Customize Keywords:
Focuses: administration Cc:

Description

The example code for the cropped-image control in the following post generates an error: https://make.wordpress.org/core/2015/07/16/new-customizer-media-controls-in-4-3-and-4-2/

This code:

$wp_customize->add_control( new WP_Customize_Cropped_Image_Control( $wp_customize, 'cropped_image', array(
    'section'     => 'background_image',
    'label'       => __( 'Croppable Image' ),
    'flex_width'  => true, // Allow any width, making the specified value recommended. False by default.
    'flex_height' => false, // Require the resulting image to be exactly as tall as the height attribute (default).
    'width'       => 1920,
    'height'      => 1080,
) ) );

Generates this error:

Fatal error: Call to a member function check_capabilities() on null in /var/www/site/public/wp/wp-includes/class-wp-customize-control.php on line 283

I use WordPress 4.3-RC2-33611

Change History (2)

#1 @ocean90
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed
  • Version trunk deleted

Hello pekz0r and welcome to Trac.

You have to define a setting for cropped_image first. Add this before your snippet:

$wp_customize->add_setting( 'cropped_image' );

WP_Customize_Manager::add_setting() supports some arguments, see WP_Customize_Setting.

This ticket was mentioned in Slack in #accessibility by afercia. View the logs.


9 years ago

Note: See TracTickets for help on using tickets.