Make WordPress Core

Ticket #34196: 34196.1.patch

File 34196.1.patch, 16.6 KB (added by azaozz, 9 years ago)
  • src/wp-admin/includes/schema.php

     
    506506        // 4.3.0
    507507        'finished_splitting_shared_terms' => 1,
    508508        'site_icon' => 0,
     509
     510        // 4.4.0
     511        'medium_large_size_w' => 768,
     512        'medium_large_size_h' => 0,
    509513        );
    510514
    511515        // 3.3
  • src/wp-admin/options.php

     
    8484$whitelist_options = array(
    8585        'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'timezone_string', 'WPLANG' ),
    8686        'discussion' => array( 'default_pingback_flag', 'default_ping_status', 'default_comment_status', 'comments_notify', 'moderation_notify', 'comment_moderation', 'require_name_email', 'comment_whitelist', 'comment_max_links', 'moderation_keys', 'blacklist_keys', 'show_avatars', 'avatar_rating', 'avatar_default', 'close_comments_for_old_posts', 'close_comments_days_old', 'thread_comments', 'thread_comments_depth', 'page_comments', 'comments_per_page', 'default_comments_page', 'comment_order', 'comment_registration' ),
    87         'media' => array( 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'large_size_w', 'large_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type' ),
     87        'media' => array( 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'medium_large_size_w', 'medium_large_size_h', 'large_size_w', 'large_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type' ),
    8888        'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'show_on_front', 'page_on_front', 'page_for_posts', 'blog_public' ),
    8989        'writing' => array( 'default_category', 'default_email_category', 'default_link_category', 'default_post_format' )
    9090);
  • src/wp-includes/class-wp-image-editor-gd.php

     
    212212         * @access public
    213213         *
    214214         * @param array $sizes {
    215          *     An array of image size arrays. Default sizes are 'small', 'medium', 'large'.
     215         *     An array of image size arrays. Default sizes are 'small', 'medium', 'medium_large', 'large'.
    216216         *
    217217         *     Either a height or width must be provided.
    218218         *     If one of the two is set to null, the resize will
  • src/wp-includes/class-wp-image-editor-imagick.php

     
    270270         * @access public
    271271         *
    272272         * @param array $sizes {
    273          *     An array of image size arrays. Default sizes are 'small', 'medium', 'large'.
     273         *     An array of image size arrays. Default sizes are 'small', 'medium', 'medium_large', 'large'.
    274274         *
    275275         *     Either a height or width must be provided.
    276276         *     If one of the two is set to null, the resize will
  • src/wp-includes/class-wp-xmlrpc-server.php

     
    513513                                'readonly'      => false,
    514514                                'option'        => 'medium_size_h'
    515515                        ),
     516                        'medium_large_size_w'   => array(
     517                                'desc'          => __( 'Medium-Large size image width' ),
     518                                'readonly'      => false,
     519                                'option'        => 'medium_large_size_w'
     520                        ),
     521                        'medium_large_size_h'   => array(
     522                                'desc'          => __( 'Medium-Large size image height' ),
     523                                'readonly'      => false,
     524                                'option'        => 'medium_large_size_h'
     525                        ),
    516526                        'large_size_w'      => array(
    517527                                'desc'          => __( 'Large size image width' ),
    518528                                'readonly'      => false,
  • src/wp-includes/formatting.php

     
    36623662                case 'thumbnail_size_h':
    36633663                case 'medium_size_w':
    36643664                case 'medium_size_h':
     3665                case 'medium_large_size_w':
     3666                case 'medium_large_size_h':
    36653667                case 'large_size_w':
    36663668                case 'large_size_h':
    36673669                case 'mailserver_port':
  • src/wp-includes/media.php

     
    1414 * The `$size` parameter accepts either an array or a string. The supported string
    1515 * values are 'thumb' or 'thumbnail' for the given thumbnail size or defaults at
    1616 * 128 width and 96 height in pixels. Also supported for the string value is
    17  * 'medium' and 'full'. The 'full' isn't actually supported, but any value other
     17 * 'medium', 'medium_large' and 'full'. The 'full' isn't actually supported, but any value other
    1818 * than the supported will result in the content_width size or 500 if that is
    1919 * not set.
    2020 *
     
    6060        elseif ( $size == 'medium' ) {
    6161                $max_width = intval(get_option('medium_size_w'));
    6262                $max_height = intval(get_option('medium_size_h'));
    63                 // if no width is set, default to the theme content width if available
     63
    6464        }
     65        elseif ( $size == 'medium_large' ) {
     66                $max_width = intval(get_option('medium_large_size_w'));
     67                $max_height = intval(get_option('medium_large_size_h'));
     68
     69                if ( intval($content_width) > 0 ) {
     70                        $max_width = min( intval($content_width), $max_width );
     71                }
     72        }
    6573        elseif ( $size == 'large' ) {
    6674                /*
    6775                 * We're inserting a large size image into the editor. If it's a really
     
    7179                 */
    7280                $max_width = intval(get_option('large_size_w'));
    7381                $max_height = intval(get_option('large_size_h'));
    74                 if ( intval($content_width) > 0 )
     82                if ( intval($content_width) > 0 ) {
    7583                        $max_width = min( intval($content_width), $max_width );
     84                }
    7685        } elseif ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) && in_array( $size, array_keys( $_wp_additional_image_sizes ) ) ) {
    7786                $max_width = intval( $_wp_additional_image_sizes[$size]['width'] );
    7887                $max_height = intval( $_wp_additional_image_sizes[$size]['height'] );
     
    706715 */
    707716function get_intermediate_image_sizes() {
    708717        global $_wp_additional_image_sizes;
    709         $image_sizes = array('thumbnail', 'medium', 'large'); // Standard sizes
     718        $image_sizes = array('thumbnail', 'medium', 'medium_large', 'large'); // Standard sizes
    710719        if ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) )
    711720                $image_sizes = array_merge( $image_sizes, array_keys( $_wp_additional_image_sizes ) );
    712721
     
    716725         * @since 2.5.0
    717726         *
    718727         * @param array $image_sizes An array of intermediate image sizes. Defaults
    719          *                           are 'thumbnail', 'medium', 'large'.
     728         *                           are 'thumbnail', 'medium', 'medium_large', 'large'.
    720729         */
    721730        return apply_filters( 'intermediate_image_sizes', $image_sizes );
    722731}
  • src/wp-includes/version.php

     
    1111 *
    1212 * @global int $wp_db_version
    1313 */
    14 $wp_db_version = 35329;
     14$wp_db_version = 35465;
    1515
    1616/**
    1717 * Holds the TinyMCE version
  • tests/phpunit/tests/media.php

     
    724724                                return array( 150, 150 );
    725725                        case 'medium':
    726726                                return array( 300, 225 );
     727                        case 'medium_large':
     728                                return array( 768, 576 );
    727729                        case 'large':
    728730                                return array( 1024, 768 );
    729731                        case 'full':
     
    742744                $uploads_dir_url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/';
    743745
    744746                $expected = $uploads_dir_url . $year_month . '/' . $image_meta['sizes']['medium']['file'] . ' ' . $image_meta['sizes']['medium']['width'] . 'w, ' .
     747                                $uploads_dir_url . $year_month . '/' . $image_meta['sizes']['medium_large']['file'] . ' ' . $image_meta['sizes']['medium_large']['width'] . 'w, ' .
    745748                                $uploads_dir_url . $year_month . '/' . $image_meta['sizes']['large']['file'] . ' ' . $image_meta['sizes']['large']['width'] . 'w, ' .
    746749                                $uploads_dir_url . $image_meta['file'] . ' ' . $image_meta['width'] . 'w';
    747750
    748751                // Set up test cases for all expected size names and a random one.
    749                 $sizes = array( 'medium', 'large', 'full', 'yoav' );
     752                $sizes = array( 'medium', 'medium_large', 'large', 'full', 'yoav' );
    750753
    751754                foreach ( $sizes as $size ) {
    752755                        $image_url = wp_get_attachment_image_url( self::$large_id, $size );
     
    773776                $uploads_dir_url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/';
    774777
    775778                $expected = $uploads_dir_url . $image_meta['sizes']['medium']['file'] . ' ' . $image_meta['sizes']['medium']['width'] . 'w, ' .
     779                                $uploads_dir_url . $image_meta['sizes']['medium_large']['file'] . ' ' . $image_meta['sizes']['medium_large']['width'] . 'w, ' .
    776780                                $uploads_dir_url . $image_meta['sizes']['large']['file'] . ' ' . $image_meta['sizes']['large']['width'] . 'w, ' .
    777781                                $uploads_dir_url . $image_meta['file'] . ' ' . $image_meta['width'] . 'w';
    778782
    779783                // Set up test cases for all expected size names and a random one.
    780                 $sizes = array( 'medium', 'large', 'full', 'yoav' );
     784                $sizes = array( 'medium', 'medium_large', 'large', 'full', 'yoav' );
    781785
    782786                foreach ( $sizes as $size ) {
    783787                        $size_array = $this->_get_image_size_array_from_name( $size );
     
    806810                $filename_base = basename( $image_meta['file'], '.png' );
    807811                $image_meta['file'] = str_replace( $filename_base, $filename_base . '-' . $hash, $image_meta['file'] );
    808812                $image_meta['sizes']['medium']['file'] = str_replace( $filename_base, $filename_base . '-' . $hash, $image_meta['sizes']['medium']['file'] );
     813                $image_meta['sizes']['medium_large']['file'] = str_replace( $filename_base, $filename_base . '-' . $hash, $image_meta['sizes']['medium_large']['file'] );
    809814                $image_meta['sizes']['large']['file'] = str_replace( $filename_base, $filename_base . '-' . $hash, $image_meta['sizes']['large']['file'] );
    810815
    811816                // Calculate a srcset array.
     
    857862                $expected = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $year_month = date('Y/m') . '/'
    858863                        . $image_meta['sizes']['medium']['file'] . ' ' . $image_meta['sizes']['medium']['width'] . 'w, ';
    859864                $expected .= 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $year_month = date('Y/m') . '/'
     865                        . $image_meta['sizes']['medium_large']['file'] . ' ' . $image_meta['sizes']['medium_large']['width'] . 'w, ';
     866                $expected .= 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $year_month = date('Y/m') . '/'
    860867                        . $image_meta['sizes']['large']['file'] . ' ' . $image_meta['sizes']['large']['width'] . 'w, ';
    861868                $expected .= 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image_meta['file'] . ' ' . $image_meta['width'] .'w';
    862869
     
    883890         */
    884891        function test_wp_get_attachment_image_sizes() {
    885892                // Test sizes against the default WP sizes.
    886                 $intermediates = array( 'thumbnail', 'medium', 'large' );
     893                $intermediates = array('thumbnail', 'medium', 'medium_large', 'large');
    887894                $image_meta = wp_get_attachment_metadata( self::$large_id );
    888895
    889896                foreach( $intermediates as $int_size ) {
  • tests/phpunit/tests/post/attachments.php

     
    3535                // intermediate copies should not exist
    3636                $this->assertFalse( image_get_intermediate_size($id, 'thumbnail') );
    3737                $this->assertFalse( image_get_intermediate_size($id, 'medium') );
     38                $this->assertFalse( image_get_intermediate_size($id, 'medium_large') );
    3839
    39                 // medium and full size will both point to the original
     40                // medium, medium_large, and full size will both point to the original
    4041                $downsize = image_downsize($id, 'medium');
    4142                $this->assertEquals( basename( $upload['file'] ), basename($downsize[0]) );
    4243                $this->assertEquals( 50, $downsize[1] );
    4344                $this->assertEquals( 50, $downsize[2] );
    4445
     46                $downsize = image_downsize($id, 'medium_large');
     47                $this->assertEquals( basename( $upload['file'] ), basename($downsize[0]) );
     48                $this->assertEquals( 50, $downsize[1] );
     49                $this->assertEquals( 50, $downsize[2] );
     50
    4551                $downsize = image_downsize($id, 'full');
    4652                $this->assertEquals( basename( $upload['file'] ), basename($downsize[0]) );
    4753                $this->assertEquals( 50, $downsize[1] );
     
    7278                $this->assertTrue( is_file($uploads['basedir'] . DIRECTORY_SEPARATOR . $thumb['path']) );
    7379
    7480                $this->assertFalse( image_get_intermediate_size($id, 'medium') );
     81                $this->assertFalse( image_get_intermediate_size($id, 'medium_large') );
    7582
    7683                // the thumb url should point to the thumbnail intermediate
    7784                $this->assertEquals( $thumb['url'], wp_get_attachment_thumb_url($id) );
     
    8289                $this->assertEquals( 150, $downsize[1] );
    8390                $this->assertEquals( 150, $downsize[2] );
    8491
    85                 // medium and full will both point to the original
     92                // medium, medium_large, and full will both point to the original
    8693                $downsize = image_downsize($id, 'medium');
    8794                $this->assertEquals( 'a2-small.jpg', basename($downsize[0]) );
    8895                $this->assertEquals( 400, $downsize[1] );
    8996                $this->assertEquals( 300, $downsize[2] );
    9097
     98                $downsize = image_downsize($id, 'medium_large');
     99                $this->assertEquals( 'a2-small.jpg', basename($downsize[0]) );
     100                $this->assertEquals( 400, $downsize[1] );
     101                $this->assertEquals( 300, $downsize[2] );
     102
    91103                $downsize = image_downsize($id, 'full');
    92104                $this->assertEquals( 'a2-small.jpg', basename($downsize[0]) );
    93105                $this->assertEquals( 400, $downsize[1] );
     
    95107
    96108        }
    97109
    98         function test_insert_image_medium() {
     110        function test_insert_image_medium_sizes() {
    99111                if ( !function_exists( 'imagejpeg' ) )
    100112                        $this->markTestSkipped( 'jpeg support unavailable' );
    101113
     
    102114                update_option('medium_size_w', 400);
    103115                update_option('medium_size_h', 0);
    104116
     117                update_option('medium_large_size_w', 600);
     118                update_option('medium_large_size_h', 0);
     119
    105120                $filename = ( DIR_TESTDATA.'/images/2007-06-17DSC_4173.JPG' );
    106121                $contents = file_get_contents($filename);
    107122
     
    120135                $this->assertEquals( '2007-06-17DSC_4173-400x602.jpg', $medium['file'] );
    121136                $this->assertTrue( is_file($uploads['basedir'] . DIRECTORY_SEPARATOR . $medium['path']) );
    122137
     138                $medium_large = image_get_intermediate_size($id, 'medium_large');
     139                $this->assertEquals( '2007-06-17DSC_4173-600x904.jpg', $medium_large['file'] );
     140                $this->assertTrue( is_file($uploads['basedir'] . DIRECTORY_SEPARATOR . $medium_large['path']) );
     141
    123142                // the thumb url should point to the thumbnail intermediate
    124143                $this->assertEquals( $thumb['url'], wp_get_attachment_thumb_url($id) );
    125144
     
    134153                $this->assertEquals( 400, $downsize[1] );
    135154                $this->assertEquals( 602, $downsize[2] );
    136155
     156                $downsize = image_downsize($id, 'medium_large');
     157                $this->assertEquals( '2007-06-17DSC_4173-600x904.jpg', basename($downsize[0]) );
     158                $this->assertEquals( 600, $downsize[1] );
     159                $this->assertEquals( 904, $downsize[2] );
     160
    137161                $downsize = image_downsize($id, 'full');
    138162                $this->assertEquals( '2007-06-17DSC_4173.jpg', basename($downsize[0]) );
    139163                $this->assertEquals( 680, $downsize[1] );
     
    148172                update_option('medium_size_w', 400);
    149173                update_option('medium_size_h', 0);
    150174
     175                update_option('medium_large_size_w', 600);
     176                update_option('medium_large_size_h', 0);
     177
    151178                $filename = ( DIR_TESTDATA.'/images/2007-06-17DSC_4173.JPG' );
    152179                $contents = file_get_contents($filename);
    153180
     
    166193                $this->assertEquals( '2007-06-17DSC_4173-400x602.jpg', $medium['file'] );
    167194                $this->assertTrue( is_file($uploads['basedir'] . DIRECTORY_SEPARATOR . $medium['path']) );
    168195
     196                $medium_large = image_get_intermediate_size($id, 'medium_large');
     197                $this->assertEquals( '2007-06-17DSC_4173-600x904.jpg', $medium_large['file'] );
     198                $this->assertTrue( is_file($uploads['basedir'] . DIRECTORY_SEPARATOR . $medium_large['path']) );
     199
    169200                $meta = wp_get_attachment_metadata($id);
    170201                $original = $meta['file'];
    171202                $this->assertTrue( is_file($uploads['basedir'] . DIRECTORY_SEPARATOR . $original) );
     
    175206
    176207                $this->assertFalse( is_file($thumb['path']) );
    177208                $this->assertFalse( is_file($medium['path']) );
     209                $this->assertFalse( is_file($medium_large['path']) );
    178210                $this->assertFalse( is_file($original) );
    179211        }
    180212