Make WordPress Core

Ticket #36255: 36255.6.diff

File 36255.6.diff, 2.9 KB (added by celloexpressions, 10 years ago)

Rough (untested) pass at revising the way the theme support works with image sizes, and adding crop support. Also updates Twenty Fifteen.

  • src/wp-content/themes/twentyfifteen/functions.php

     
    108108         *
    109109         * @since Twenty Fifteen 1.5
    110110         */
    111         add_image_size( 'twentyfifteen-logo', 248, 248 );
    112         add_theme_support( 'custom-logo', array( 'size' => 'twentyfifteen-logo' ) );
     111        add_theme_support( 'custom-logo', array(
     112                'height'      => 248,
     113                'width'       => 248,
     114                'flex-height' => true, // Allows arbitrary aspect ratios but sizes images to the requested width.
     115                'flex-width'  => false,
     116        ) );
    113117
    114118        $color_scheme  = twentyfifteen_get_color_scheme();
    115119        $default_color = trim( $color_scheme[0], '#' );
  • src/wp-includes/class-wp-customize-manager.php

     
    19591959                        'transport'      => 'postMessage',
    19601960                ) );
    19611961
    1962                 $this->add_control( new WP_Customize_Media_Control( $this, 'custom_logo', array(
    1963                         'label'    => __( 'Logo' ),
    1964                         'section'  => 'title_tagline',
    1965                         'priority' => 8,
    1966                         'mime_type' => 'image',
    1967                         'button_labels' => array(
    1968                                 'select'       => __( 'Select logo' ),
    1969                                 'change'       => __( 'Change logo' ),
    1970                                 'remove'       => __( 'Remove' ),
    1971                                 'default'      => __( 'Default' ),
    1972                                 'placeholder'  => __( 'No logo selected' ),
    1973                                 'frame_title'  => __( 'Select logo' ),
    1974                                 'frame_button' => __( 'Choose logo' ),
    1975                         ),
    1976                 ) ) );
     1962                $logo_settings = get_theme_support( 'custom-logo' );
     1963                if ( $logo_settings ) {
     1964                        $logo_defaults = array(
     1965                                'height'      => 500, // Completely arbitrary size, will be "recommended".
     1966                                'width'       => 500,
     1967                                'flex_height' => true, // Allow any aspect ratio and size by default.
     1968                                'flex_width'  => true,
     1969                        );
     1970                        if ( is_array( $logo_settings ) ) {
     1971                                $logo_settings = wp_parse_args( $logo_settings, $logo_defaults );
     1972                        }
     1973                        $this->add_control( new WP_Customize_Cropped_Image_Control( $this, 'custom_logo', array(
     1974                                'label'       => __( 'Logo' ),
     1975                                'section'     => 'title_tagline',
     1976                                'priority'    => 8,
     1977                                'height'      => $logo_settings['height'],
     1978                                'width'       => $logo_settings['width'],
     1979                                'flex_height' => $logo_settings['flex_height'],
     1980                                'flex_width'  => $logo_settings['flex_width'],
     1981                                'button_labels' => array(
     1982                                        'select'       => __( 'Select logo' ),
     1983                                        'change'       => __( 'Change logo' ),
     1984                                        'remove'       => __( 'Remove' ),
     1985                                        'default'      => __( 'Default' ),
     1986                                        'placeholder'  => __( 'No logo selected' ),
     1987                                        'frame_title'  => __( 'Select logo' ),
     1988                                        'frame_button' => __( 'Choose logo' ),
     1989                                ),
     1990                        ) ) );
     1991                }
    19771992
    19781993                $this->selective_refresh->add_partial( 'site_logo', array(
    19791994                        'settings'            => array( 'site_logo' ),