WordPress.org

Make WordPress Core


Ignore:
Timestamp:
08/22/2016 04:36:42 AM (4 years ago)
Author:
wonderboymusic
Message:

Media: add a function, wp_get_additional_image_sizes(), that wraps the retrieval of the global $_wp_additional_image_sizes. Removes 6 global imports.

See #37699.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/image.php

    r37488 r38303  
    6868 * @since 2.1.0
    6969 *
    70  * @global array $_wp_additional_image_sizes
    71  *
    7270 * @param int $attachment_id Attachment Id to process.
    7371 * @param string $file Filepath of the Attached image.
     
    8886
    8987        // Make thumbnails and other intermediate sizes.
    90         global $_wp_additional_image_sizes;
     88        $_wp_additional_image_sizes = wp_get_additional_image_sizes();
    9189
    9290        $sizes = array();
    9391        foreach ( get_intermediate_image_sizes() as $s ) {
    9492            $sizes[$s] = array( 'width' => '', 'height' => '', 'crop' => false );
    95             if ( isset( $_wp_additional_image_sizes[$s]['width'] ) )
    96                 $sizes[$s]['width'] = intval( $_wp_additional_image_sizes[$s]['width'] ); // For theme-added sizes
    97             else
    98                 $sizes[$s]['width'] = get_option( "{$s}_size_w" ); // For default sizes set in options
    99             if ( isset( $_wp_additional_image_sizes[$s]['height'] ) )
    100                 $sizes[$s]['height'] = intval( $_wp_additional_image_sizes[$s]['height'] ); // For theme-added sizes
    101             else
    102                 $sizes[$s]['height'] = get_option( "{$s}_size_h" ); // For default sizes set in options
    103             if ( isset( $_wp_additional_image_sizes[$s]['crop'] ) )
    104                 $sizes[$s]['crop'] = $_wp_additional_image_sizes[$s]['crop']; // For theme-added sizes
    105             else
    106                 $sizes[$s]['crop'] = get_option( "{$s}_crop" ); // For default sizes set in options
     93            if ( isset( $_wp_additional_image_sizes[$s]['width'] ) ) {
     94                // For theme-added sizes
     95                $sizes[$s]['width'] = intval( $_wp_additional_image_sizes[$s]['width'] );
     96            } else {
     97                // For default sizes set in options
     98                $sizes[$s]['width'] = get_option( "{$s}_size_w" );
     99            }
     100
     101            if ( isset( $_wp_additional_image_sizes[$s]['height'] ) ) {
     102                // For theme-added sizes
     103                $sizes[$s]['height'] = intval( $_wp_additional_image_sizes[$s]['height'] );
     104            } else {
     105                // For default sizes set in options
     106                $sizes[$s]['height'] = get_option( "{$s}_size_h" );
     107            }
     108
     109            if ( isset( $_wp_additional_image_sizes[$s]['crop'] ) ) {
     110                // For theme-added sizes
     111                $sizes[$s]['crop'] = $_wp_additional_image_sizes[$s]['crop'];
     112            } else {
     113                // For default sizes set in options
     114                $sizes[$s]['crop'] = get_option( "{$s}_crop" );
     115            }
    107116        }
    108117
Note: See TracChangeset for help on using the changeset viewer.