Ticket #12146: 12146.2.patch
| File 12146.2.patch, 1.8 KB (added by , 16 years ago) |
|---|
-
wp-admin/includes/post.php
1103 1103 * @return string html 1104 1104 */ 1105 1105 function _wp_post_thumbnail_html( $thumbnail_id = NULL ) { 1106 global $content_width, $_wp_additional_image_sizes; 1106 global $_wp_additional_image_sizes; 1107 1107 1108 $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>'; 1108 1109 1109 1110 if ( $thumbnail_id && get_post( $thumbnail_id ) ) { 1110 $old_content_width = $content_width;1111 $content_width = 266;1112 1111 if ( !isset( $_wp_additional_image_sizes['post-thumbnail'] ) ) 1113 1112 $thumbnail_html = wp_get_attachment_image( $thumbnail_id, array( $content_width, $content_width ) ); 1114 1113 else 1115 1114 $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'post-thumbnail' ); 1116 1115 if ( !empty( $thumbnail_html ) ) { 1116 // Downsize the thumbnail HTML to fit in the meta box 1117 if ( preg_match( '#width="([0-9]+)"#i', $thumbnail_html, $width ) && $width[1] > 266 && preg_match( '#height="([0-9]+)"#i', $thumbnail_html, $height ) ) { 1118 $newdims = wp_constrain_dimensions( $width[1], $height[1], 266 ); 1119 $thumbnail_html = str_replace( array( $width[0], $height[0] ), array( "width=\"{$newdims[0]}\"", "height=\"{$newdims[1]}\"" ), $thumbnail_html ); 1120 } 1121 1117 1122 $content = '<a href="#" id="set-post-thumbnail" onclick="jQuery(\'#add_image\').click();return false;">' . $thumbnail_html . '</a>'; 1118 1123 $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail();return false;">' . esc_html__( 'Remove thumbnail' ) . '</a></p>'; 1119 1124 } 1120 $content_width = $old_content_width;1121 1125 } 1122 1126 1123 1127 return apply_filters( 'admin_post_thumbnail_html', $content );