Changeset 22094 for trunk/wp-includes/deprecated.php
- Timestamp:
- 10/01/2012 08:59:06 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/deprecated.php
r21996 r22094 3207 3207 3208 3208 /** 3209 * Load an image from a string, if PHP supports it. 3210 * 3211 * @since 2.1.0 3212 * @deprecated 3.5.0 3213 * @see WP_Image_Editor 3214 * 3215 * @param string $file Filename of the image to load. 3216 * @return resource The resulting image resource on success, Error string on failure. 3217 */ 3218 function wp_load_image( $file ) { 3219 _deprecated_function( __FUNCTION__, '3.5', 'WP_Image_Editor' ); 3220 3221 if ( is_numeric( $file ) ) 3222 $file = get_attached_file( $file ); 3223 3224 if ( ! file_exists( $file ) ) 3225 return sprintf(__('File “%s” doesn’t exist?'), $file); 3226 3227 if ( ! function_exists('imagecreatefromstring') ) 3228 return __('The GD image library is not installed.'); 3229 3230 // Set artificially high because GD uses uncompressed images in memory 3231 @ini_set( 'memory_limit', apply_filters( 'image_memory_limit', WP_MAX_MEMORY_LIMIT ) ); 3232 $image = imagecreatefromstring( file_get_contents( $file ) ); 3233 3234 if ( !is_resource( $image ) ) 3235 return sprintf(__('File “%s” is not an image.'), $file); 3236 3237 return $image; 3238 } 3239 3240 /** 3241 * Scale down an image to fit a particular size and save a new copy of the image. 3242 * 3243 * The PNG transparency will be preserved using the function, as well as the 3244 * image type. If the file going in is PNG, then the resized image is going to 3245 * be PNG. The only supported image types are PNG, GIF, and JPEG. 3246 * 3247 * Some functionality requires API to exist, so some PHP version may lose out 3248 * support. This is not the fault of WordPress (where functionality is 3249 * downgraded, not actual defects), but of your PHP version. 3250 * 3251 * @since 2.5.0 3252 * @deprecated 3.5.0 3253 * @see WP_Image_Editor 3254 * 3255 * @param string $file Image file path. 3256 * @param int $max_w Maximum width to resize to. 3257 * @param int $max_h Maximum height to resize to. 3258 * @param bool $crop Optional. Whether to crop image or resize. 3259 * @param string $suffix Optional. File suffix. 3260 * @param string $dest_path Optional. New image file path. 3261 * @param int $jpeg_quality Optional, default is 90. Image quality percentage. 3262 * @return mixed WP_Error on failure. String with new destination path. 3263 */ 3264 function image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ) { 3265 _deprecated_function( __FUNCTION__, '3.5', 'WP_Image_Editor' ); 3266 3267 $editor = WP_Image_Editor::get_instance( $file ); 3268 if ( is_wp_error( $editor ) ) 3269 return $editor; 3270 $editor->set_quality( $jpeg_quality ); 3271 3272 $resized = $editor->resize( $max_w, $max_h, $crop ); 3273 if ( is_wp_error( $resized ) ) 3274 return $resized; 3275 3276 $dest_file = $editor->generate_filename( $suffix, $dest_path ); 3277 $saved = $editor->save( $dest_file ); 3278 3279 if ( is_wp_error( $saved ) ) 3280 return $saved; 3281 3282 return $dest_file; 3283 } 3284 3285 /** 3209 3286 * Retrieve a single post, based on post ID. 3210 3287 *
Note: See TracChangeset
for help on using the changeset viewer.