Changeset 6747 for trunk/wp-admin/includes/media.php
- Timestamp:
- 02/07/2008 04:22:38 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/media.php
r6726 r6747 183 183 add_filter('async_upload_image', 'async_image_callback'); 184 184 185 // scale down the default size of an image so it's a better fit for the editor and theme 186 function image_constrain_size_for_editor($width, $height) { 187 // pick a reasonable default width for the image 188 // $content_width might be set in the theme's functions.php 189 if ( !empty($GLOBALS['content_width']) ) 190 $max_width = $GLOBALS['content_width']; 191 else 192 $max_width = 500; 193 194 $max_width = apply_filters( 'editor_max_image_width', $max_width ); 195 $max_height = apply_filters( 'editor_max_image_height', $max_width ); 196 197 return wp_shrink_dimensions( $width, $height, $max_width, $max_height ); 198 } 185 199 186 200 function image_send_to_editor($id, $alt, $title, $align, $url='') { … … 190 204 191 205 $hwstring = ''; 192 if ( isset($meta['width'], $meta['height']) ) 193 $hwstring = ' width="'.intval($meta['width']).'" height="'.intval($meta['height']).'"'; 206 if ( isset($meta['width'], $meta['height']) ) { 207 list( $width, $height ) = image_constrain_size_for_editor( $meta['width'], $meta['height'] ); 208 $hwstring = ' width="'.intval($width).'" height="'.intval($height).'"'; 209 } 194 210 195 211 $html = '<img src="'.attribute_escape($img_src).'" rel="attachment wp-att-'.attribute_escape($id).'" alt="'.attribute_escape($alt).'" title="'.attribute_escape($title).'"'.$hwstring.' class="align-'.attribute_escape($align).'" />'; … … 197 213 if ( $url ) 198 214 $html = '<a href="'.attribute_escape($url).'">'.$html.'</a>'; 215 216 $html = apply_filters( 'image_send_to_editor', $html, $id, $alt, $title, $align, $url ); 199 217 200 218 media_send_to_editor($html);
Note: See TracChangeset
for help on using the changeset viewer.