Make WordPress Core

Changeset 12659


Ignore:
Timestamp:
01/08/2010 08:51:12 AM (15 years ago)
Author:
westi
Message:

Introduce a single function for getting all the intermediate image sizes to be used both when adding attachements and deleting. Fixes #10263 props scribu.

Location:
trunk
Files:
3 edited

Legend:

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

    r12584 r12659  
    103103        // make thumbnails and other intermediate sizes
    104104        global $_wp_additional_image_sizes;
    105         $temp_sizes = array('thumbnail', 'medium', 'large'); // Standard sizes
    106         if ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) )
    107             $temp_sizes = array_merge( $temp_sizes, array_keys( $_wp_additional_image_sizes ) );
    108 
    109         $temp_sizes = apply_filters( 'intermediate_image_sizes', $temp_sizes );
    110 
    111         foreach ( $temp_sizes as $s ) {
     105
     106        foreach ( get_intermediate_image_sizes() as $s ) {
    112107            $sizes[$s] = array( 'width' => '', 'height' => '', 'crop' => FALSE );
    113108            if ( isset( $_wp_additional_image_sizes[$s]['width'] ) )
  • trunk/wp-includes/media.php

    r12524 r12659  
    505505    }
    506506    return $data;
     507}
     508
     509/**
     510 * Get the available image sizes
     511 * @since 3.0
     512 * @return array Returns a filtered array of image size strings
     513 */
     514function get_intermediate_image_sizes() {
     515    global $_wp_additional_image_sizes;
     516    $image_sizes = array('thumbnail', 'medium', 'large'); // Standard sizes
     517    if ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) )
     518        $image_sizes = array_merge( $image_sizes, array_keys( $_wp_additional_image_sizes ) );
     519
     520    return apply_filters( 'intermediate_image_sizes', $image_sizes );
    507521}
    508522
  • trunk/wp-includes/post.php

    r12652 r12659  
    29472947
    29482948    // remove intermediate and backup images if there are any
    2949     $sizes = apply_filters('intermediate_image_sizes', array('thumbnail', 'medium', 'large'));
    2950     foreach ( $sizes as $size ) {
     2949    foreach ( get_intermediate_image_sizes() as $size ) {
    29512950        if ( $intermediate = image_get_intermediate_size($post_id, $size) ) {
    29522951            $intermediate_file = apply_filters('wp_delete_file', $intermediate['path']);
Note: See TracChangeset for help on using the changeset viewer.