WordPress.org

Make WordPress Core

Ticket #34196: moderate-size.diff

File moderate-size.diff, 16.9 KB (added by mikeschroder, 4 years ago)

Very rough addition of "moderate" size of 768x768

  • src/wp-admin/custom-background.php

    diff --git a/src/wp-admin/custom-background.php b/src/wp-admin/custom-background.php
    index dba32c6..71f43a0 100644
    a b if ( current_theme_supports( 'custom-background', 'default-color' ) ) 
    467467                if ( ! current_user_can('edit_theme_options') || ! isset( $_POST['attachment_id'] ) ) exit;
    468468                $attachment_id = absint($_POST['attachment_id']);
    469469                /** This filter is documented in wp-admin/includes/media.php */
    470                 $sizes = array_keys(apply_filters( 'image_size_names_choose', array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size')) ));
     470                $sizes = array_keys(apply_filters( 'image_size_names_choose', array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'moderate' => __('Moderate'), 'large' => __('Large'), 'full' => __('Full Size')) ));
    471471                $size = 'thumbnail';
    472472                if ( in_array( $_POST['size'], $sizes ) )
    473473                        $size = esc_attr( $_POST['size'] );
  • src/wp-admin/includes/media.php

    diff --git a/src/wp-admin/includes/media.php b/src/wp-admin/includes/media.php
    index c1f7f5f..387f691 100644
    a b function the_media_upload_tabs() { 
    112112 * @param string  $align   image css alignment property
    113113 * @param string  $url     image src url
    114114 * @param string  $rel     image rel attribute
    115  * @param string  $size    image size (thumbnail, medium, large, full or added with add_image_size() )
     115 * @param string  $size    image size (thumbnail, medium, moderate, large, full or added with add_image_size() )
    116116 * @return string the html to insert into editor
    117117 */
    118118function get_image_send_to_editor( $id, $caption, $title, $align, $url='', $rel = '', $size='medium', $alt = '' ) {
    function get_image_send_to_editor( $id, $caption, $title, $align, $url='', $rel 
    159159 * @param string $title image title attribute
    160160 * @param string $align image css alignment property
    161161 * @param string $url image src url
    162  * @param string $size image size (thumbnail, medium, large, full or added with add_image_size() )
     162 * @param string $size image size (thumbnail, medium, moderate, large, full or added with add_image_size() )
    163163 * @return string
    164164 */
    165165function image_add_caption( $html, $id, $caption, $title, $align, $url, $size, $alt = '' ) {
    function image_size_input_fields( $post, $check = '' ) { 
    972972         * @since 3.3.0
    973973         *
    974974         * @param array $size_names Array of image sizes and their names. Default values
    975          *                          include 'Thumbnail', 'Medium', 'Large', 'Full Size'.
     975         *                          include 'Thumbnail', 'Medium', 'Moderate', 'Large', 'Full Size'.
    976976         */
    977977        $size_names = apply_filters( 'image_size_names_choose', array(
    978978                'thumbnail' => __( 'Thumbnail' ),
    979979                'medium'    => __( 'Medium' ),
     980                'moderate'  => __( 'Moderate' ),
    980981                'large'     => __( 'Large' ),
    981982                'full'      => __( 'Full Size' )
    982983        ) );
  • src/wp-admin/includes/schema.php

    diff --git a/src/wp-admin/includes/schema.php b/src/wp-admin/includes/schema.php
    index 1d67e76..12babd4 100644
    a b function populate_options() { 
    506506
    507507        // 4.3.0
    508508        'finished_splitting_shared_terms' => 1,
     509
     510        // 4.4.0
     511        'moderate_size_w' => 768,
     512        'moderate_size_h' => 768,
    509513        );
    510514
    511515        // 3.3
  • src/wp-admin/options-media.php

    diff --git a/src/wp-admin/options-media.php b/src/wp-admin/options-media.php
    index d4d4318..a45c28e 100644
    a b include( ABSPATH . 'wp-admin/admin-header.php' ); 
    7272</tr>
    7373
    7474<tr>
     75<th scope="row"><?php _e('Moderate size') ?></th>
     76<td><fieldset><legend class="screen-reader-text"><span><?php _e('Moderate size'); ?></span></legend>
     77<label for="moderate_size_w"><?php _e('Max Width'); ?></label>
     78<input name="moderate_size_w" type="number" step="1" min="0" id="moderate_size_w" value="<?php form_option('moderate_size_w'); ?>" class="small-text" />
     79<label for="moderate_size_h"><?php _e('Max Height'); ?></label>
     80<input name="moderate_size_h" type="number" step="1" min="0" id="moderate_size_h" value="<?php form_option('moderate_size_h'); ?>" class="small-text" />
     81</fieldset></td>
     82</tr>
     83
     84<tr>
    7585<th scope="row"><?php _e('Large size') ?></th>
    7686<td><fieldset><legend class="screen-reader-text"><span><?php _e('Large size'); ?></span></legend>
    7787<label for="large_size_w"><?php _e('Max Width'); ?></label>
  • src/wp-admin/options.php

    diff --git a/src/wp-admin/options.php b/src/wp-admin/options.php
    index 017725d..3e00b28 100644
    a b if ( is_multisite() && ! is_super_admin() && 'update' != $action ) { 
    8484$whitelist_options = array(
    8585        'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', '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', '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', 'moderate_size_w', 'moderate_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

    diff --git a/src/wp-includes/class-wp-image-editor-gd.php b/src/wp-includes/class-wp-image-editor-gd.php
    index 53f0837..a37d437 100644
    a b class WP_Image_Editor_GD extends WP_Image_Editor { 
    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', 'moderate', '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

    diff --git a/src/wp-includes/class-wp-image-editor-imagick.php b/src/wp-includes/class-wp-image-editor-imagick.php
    index f4d8f3b..a629a01 100644
    a b class WP_Image_Editor_Imagick extends WP_Image_Editor { 
    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', 'moderate', '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

    diff --git a/src/wp-includes/class-wp-xmlrpc-server.php b/src/wp-includes/class-wp-xmlrpc-server.php
    index 380a28d..9c1d2c8 100644
    a b class wp_xmlrpc_server extends IXR_Server { 
    498498                                'readonly'      => false,
    499499                                'option'        => 'medium_size_h'
    500500                        ),
     501                        'moderate_size_w'   => array(
     502                                'desc'          => __( 'Moderate size image width' ),
     503                                'readonly'      => false,
     504                                'option'        => 'moderate_size_w'
     505                        ),
     506                        'moderate_size_h'   => array(
     507                                'desc'          => __( 'Moderate size image height' ),
     508                                'readonly'      => false,
     509                                'option'        => 'moderate_size_h'
     510                        ),
    501511                        'large_size_w'      => array(
    502512                                'desc'          => __( 'Large size image width' ),
    503513                                'readonly'      => false,
  • src/wp-includes/formatting.php

    diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php
    index b3f18ee..0fc662a 100644
    a b function get_html_split_regex() { 
    611611                        . ')*+'         // Loop possessively.
    612612                        . '(?:]]>)?';   // End of comment. If not found, match all input.
    613613
    614                 $escaped = 
     614                $escaped =
    615615                          '(?='           // Is the element escaped?
    616616                        .    '!--'
    617617                        . '|'
    function sanitize_option( $option, $value ) { 
    36473647                case 'thumbnail_size_h':
    36483648                case 'medium_size_w':
    36493649                case 'medium_size_h':
     3650                case 'moderate_size_w':
     3651                case 'moderate_size_h':
    36503652                case 'large_size_w':
    36513653                case 'large_size_h':
    36523654                case 'mailserver_port':
  • src/wp-includes/js/media-views.js

    diff --git a/src/wp-includes/js/media-views.js b/src/wp-includes/js/media-views.js
    index c932f21..de141ec 100644
    a b Attachment = View.extend({ 
    29962996                                matched = sizes[ size ];
    29972997                        } else if ( sizes.large ) {
    29982998                                matched = sizes.large;
     2999                        } else if ( sizes.moderate ) {
     3000                                matched = sizes.moderate;
    29993001                        } else if ( sizes.thumbnail ) {
    30003002                                matched = sizes.thumbnail;
    30013003                        } else if ( sizes.full ) {
  • src/wp-includes/js/media/views/attachment.js

    diff --git a/src/wp-includes/js/media/views/attachment.js b/src/wp-includes/js/media/views/attachment.js
    index 17266a5..dcfc65f 100644
    a b Attachment = View.extend({ 
    361361                                matched = sizes[ size ];
    362362                        } else if ( sizes.large ) {
    363363                                matched = sizes.large;
     364                        } else if ( sizes.moderate ) {
     365                                matched = sizes.moderate;
    364366                        } else if ( sizes.thumbnail ) {
    365367                                matched = sizes.thumbnail;
    366368                        } else if ( sizes.full ) {
  • src/wp-includes/js/tinymce/langs/wp-langs-en.js

    diff --git a/src/wp-includes/js/tinymce/langs/wp-langs-en.js b/src/wp-includes/js/tinymce/langs/wp-langs-en.js
    index 65d9669..93a9134 100644
    a b  
    489489                size: "Size",
    490490                thumbnail: "Thumbnail",
    491491                medium: "Medium",
     492                moderate: "Moderate",
    492493                full_size: "Full Size",
    493494                current_link: "Current Link",
    494495                link_to_img: "Link to Image",
  • src/wp-includes/media-template.php

    diff --git a/src/wp-includes/media-template.php b/src/wp-includes/media-template.php
    index ae39d57..aa8efc8 100644
    a b function wp_print_media_templates() { 
    687687                                        $sizes = apply_filters( 'image_size_names_choose', array(
    688688                                                'thumbnail' => __('Thumbnail'),
    689689                                                'medium'    => __('Medium'),
     690                                                'moderate'  => __('Moderate'),
    690691                                                'large'     => __('Large'),
    691692                                                'full'      => __('Full Size'),
    692693                                        ) );
  • src/wp-includes/media.php

    diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php
    index e0ed8f4..16bd2fe 100644
    a b  
    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 * 'moderate', 'medium' 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 *
    function image_constrain_size_for_editor( $width, $height, $size = 'medium', $co 
    6161                $max_height = intval(get_option('medium_size_h'));
    6262                // if no width is set, default to the theme content width if available
    6363        }
     64        elseif ( $size == 'moderate' ) {
     65                /*
     66                 * We're inserting a moderately sized image into the editor. If it's a really
     67                 * big image we'll scale it down to fit reasonably within the editor
     68                 * itself, and within the theme's content width if it's known. The user
     69                 * can resize it in the editor if they wish.
     70                 */
     71                $max_width = intval(get_option('moderate_size_w'));
     72                $max_height = intval(get_option('moderate_size_h'));
     73                if ( intval($content_width) > 0 )
     74                        $max_width = min( intval($content_width), $max_width );
     75        }
    6476        elseif ( $size == 'large' ) {
    6577                /*
    6678                 * We're inserting a large size image into the editor. If it's a really
    function image_get_intermediate_size( $post_id, $size = 'thumbnail' ) { 
    672684 */
    673685function get_intermediate_image_sizes() {
    674686        global $_wp_additional_image_sizes;
    675         $image_sizes = array('thumbnail', 'medium', 'large'); // Standard sizes
     687        $image_sizes = array('thumbnail', 'medium', 'moderate', 'large'); // Standard sizes
    676688        if ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) )
    677689                $image_sizes = array_merge( $image_sizes, array_keys( $_wp_additional_image_sizes ) );
    678690
    function get_intermediate_image_sizes() { 
    682694         * @since 2.5.0
    683695         *
    684696         * @param array $image_sizes An array of intermediate image sizes. Defaults
    685          *                           are 'thumbnail', 'medium', 'large'.
     697         *                           are 'thumbnail', 'medium', 'moderate', 'large'.
    686698         */
    687699        return apply_filters( 'intermediate_image_sizes', $image_sizes );
    688700}
    function wp_prepare_attachment_for_js( $attachment ) { 
    29012913                $possible_sizes = apply_filters( 'image_size_names_choose', array(
    29022914                        'thumbnail' => __('Thumbnail'),
    29032915                        'medium'    => __('Medium'),
     2916                        'moderate'  => __('Moderate'),
    29042917                        'large'     => __('Large'),
    29052918                        'full'      => __('Full Size'),
    29062919                ) );
    function wp_prepare_attachment_for_js( $attachment ) { 
    29302943                                $size_meta = $meta['sizes'][ $size ];
    29312944
    29322945                                // We have the actual image size, but might need to further constrain it if content_width is narrower.
    2933                                 // Thumbnail, medium, and full sizes are also checked against the site's height/width options.
     2946                                // Thumbnail, medium, moderate, and full sizes are also checked against the site's height/width options.
    29342947                                list( $width, $height ) = image_constrain_size_for_editor( $size_meta['width'], $size_meta['height'], $size, 'edit' );
    29352948
    29362949                                $sizes[ $size ] = array(
  • src/wp-includes/version.php

    diff --git a/src/wp-includes/version.php b/src/wp-includes/version.php
    index 7c88c6c..c27abed 100644
    a b $wp_version = '4.4-alpha-33636-src'; 
    1111 *
    1212 * @global int $wp_db_version
    1313 */
    14 $wp_db_version = 34528;
     14$wp_db_version = 34529;
    1515
    1616/**
    1717 * Holds the TinyMCE version
  • tests/phpunit/tests/media.php

    diff --git a/tests/phpunit/tests/media.php b/tests/phpunit/tests/media.php
    index f4888af..902584d 100644
    a b EOF; 
    762762                                'descriptor' => 'w',
    763763                                'value'      => $image['sizes']['medium']['width'],
    764764                        ),
     765                        array(
     766                                'url'        => 'http://example.org/wp-content/uploads/' . $year_month . '/' . $image['sizes']['moderate']['file'],
     767                                'descriptor' => 'w',
     768                                'value'      => $image['sizes']['moderate']['width'],
     769                        ),
    765770                        array(
    766771                                'url'        => 'http://example.org/wp-content/uploads/' . $year_month . '/' . $image['sizes']['large']['file'],
    767772                                'descriptor' => 'w',
    EOF; 
    805810                                'value'      => $image['sizes']['medium']['width'],
    806811                        ),
    807812                        array(
     813                                'url'        => 'http://example.org/wp-content/uploads/' . $image['sizes']['moderate']['file'],
     814                                'descriptor' => 'w',
     815                                'value'      => $image['sizes']['moderate']['width'],
     816                        ),
     817                        array(
    808818                                'url'        => 'http://example.org/wp-content/uploads/' . $image['sizes']['large']['file'],
    809819                                'descriptor' => 'w',
    810820                                'value'      => $image['sizes']['large']['width'],
    EOF; 
    817827                );
    818828
    819829                // Set up test cases for all expected size names and a random one.
    820                 $sizes = array( 'medium', 'large', 'full', 'yoav' );
     830                $sizes = array( 'medium', 'large', 'moderate', 'full', 'yoav' );
    821831
    822832                foreach ( $sizes as $size ) {
    823833                        $this->assertSame( $expected, wp_get_attachment_image_srcset_array( $id, $size ) );
    EOF; 
    917927                $expected = 'http://example.org/wp-content/uploads/' . $year_month = date('Y/m') . '/'
    918928                        . $image['sizes']['medium']['file'] . ' ' . $image['sizes']['medium']['width'] . 'w, ';
    919929                $expected .= 'http://example.org/wp-content/uploads/' . $year_month = date('Y/m') . '/'
     930                        . $image['sizes']['moderate']['file'] . ' ' . $image['sizes']['moderate']['width'] . 'w, ';
     931                $expected .= 'http://example.org/wp-content/uploads/' . $year_month = date('Y/m') . '/'
    920932                        . $image['sizes']['large']['file'] . ' ' . $image['sizes']['large']['width'] . 'w, ';
    921933                $expected .= 'http://example.org/wp-content/uploads/' . $image['file'] . ' ' . $image['width'] .'w';
    922934
    EOF; 
    951963                global $content_width;
    952964
    953965                // Test sizes against the default WP sizes.
    954                 $intermediates = array('thumbnail', 'medium', 'large');
     966                $intermediates = array('thumbnail', 'medium', 'moderate', 'large');
    955967
    956968                foreach( $intermediates as $int ) {
    957969                        $width = get_option( $int . '_size_w' );