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/post.php

    r12336 r12342  
    10711071 */
    10721072function _wp_post_thumbnail_html( $thumbnail_id = NULL ) {
     1073    global $content_width, $_wp_additional_image_sizes;
    10731074    $content = '<p class="hide-if-no-js"><a href="#" id="set-post-thumbnail" onclick="jQuery(\'#add_image\').click();return false;">' . esc_html__( 'Set thumbnail' ) . '</a></p>';
    10741075
    10751076    if ( $thumbnail_id && get_post( $thumbnail_id ) ) {
    1076         $thumbnail_html = wp_get_attachment_image($thumbnail_id, array( 266, 266 ) );
     1077        $old_content_width = $content_width;
     1078        $content_width = 266;
     1079        if ( !isset( $_wp_additional_image_sizes['post-image'] ) )
     1080            $thumbnail_html = wp_get_attachment_image( $thumbnail_id, array( $content_width, $content_width ) );
     1081        else
     1082            $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'post-image' );
    10771083        if ( !empty( $thumbnail_html ) ) {
    10781084            $content = '<a href="#" id="set-post-thumbnail" onclick="jQuery(\'#add_image\').click();return false;">' . $thumbnail_html . '</a>';
    10791085            $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail();return false;">' . esc_html__( 'Remove thumbnail' ) . '</a></p>';
    10801086        }
     1087        $content_width = $old_content_width;
    10811088    }
    10821089
Note: See TracChangeset for help on using the changeset viewer.