WordPress.org

Make WordPress Core


Ignore:
Timestamp:
12/08/2009 09:08:19 PM (11 years ago)
Author:
markjaquith
Message:

Introducing set_post_image_size(w, h, crop) so themes can register their special size/crop for canonical post images. WP will create this size/crop upon upload, so your canonical post images fit your space exactly!

File:
1 edited

Legend:

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

    r12163 r12342  
    9999
    100100        // make thumbnails and other intermediate sizes
    101         $sizes = apply_filters( 'intermediate_image_sizes', array('thumbnail', 'medium', 'large') );
    102 
    103         foreach ($sizes as $size) {
    104             $resized = image_make_intermediate_size( $file, get_option("{$size}_size_w"), get_option("{$size}_size_h"), get_option("{$size}_crop") );
     101        global $_wp_additional_image_sizes;
     102        $temp_sizes = array('thumbnail', 'medium', 'large'); // Standard sizes
     103        if ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) )
     104            $temp_sizes = array_merge( $temp_sizes, array_keys( $_wp_additional_image_sizes ) );
     105
     106        $temp_sizes = apply_filters( 'intermediate_image_sizes', $temp_sizes );
     107
     108        foreach ( $temp_sizes as $s ) {
     109            $sizes[$s] = array( 'width' => '', 'height' => '', 'crop' => FALSE );
     110            if ( isset( $_wp_additional_image_sizes[$s]['width'] ) )
     111                $sizes[$s]['width'] = intval( $_wp_additional_image_sizes[$s]['width'] ); // For theme-added sizes
     112            else
     113                $sizes[$s]['width'] = get_option( "{$size}_size_w" ); // For default sizes set in options
     114            if ( isset( $_wp_additional_image_sizes[$s]['height'] ) )
     115                $sizes[$s]['height'] = intval( $_wp_additional_image_sizes[$s]['height'] ); // For theme-added sizes
     116            else
     117                $sizes[$s]['height'] = get_option( "{$size}_size_h" ); // For default sizes set in options
     118            if ( isset( $_wp_additional_image_sizes[$s]['crop'] ) )
     119                $sizes[$s]['crop'] = intval( $_wp_additional_image_sizes[$s]['crop'] ); // For theme-added sizes
     120            else
     121                $sizes[$s]['crop'] = get_option( "{$size}_crop" ); // For default sizes set in options
     122        }
     123
     124        $sizes = apply_filters( 'intermediate_image_sizes_advanced', $sizes );
     125
     126        foreach ($sizes as $size => $size_data ) {
     127            $resized = image_make_intermediate_size( $file, $size_data['width'], $size_data['height'], $size_data['crop'] );
    105128            if ( $resized )
    106129                $metadata['sizes'][$size] = $resized;
Note: See TracChangeset for help on using the changeset viewer.