- 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細)
関数リファレンス/image downsize
[http://wpdocs.sourceforge.jp{{localurl: テンプレート:en テンプレート:ja }} 日本語] •
目次
Description
Scale an image to fit a particular size (such as 'thumb'
or 'medium'
).
The $max_/$min_width
for the Reserved Names will always be what you defined under "admin UI" » "Settings" » "Media". You may go and blame the internals of image_constrain_size_for_editor() for it.
Parameters
- $id
- (integer) The ID of the image. Required.
- $size
- (string) Size of image, can be 'thumbnail' or 'medium'. Default is 'medium'.
Returns
- (bool|array) False on failure, array on success. Array with image url, width, height, and whether is intermediate size, in that order is returned on success is returned. $is_intermediate is true if $url is a resized image, false if it is the original.
Defined
image_downsize() is located in wp-includes/media.php
.
Examples
Add a function to select medium attachment images
Maybe you already know wp_get_attachment_thumb_url();. Now I'm showing how to do the same thing to return the url for the medium sized attachment.
function wp_get_attachment_medium_url( $id ) { $medium_array = image_downsize( $id, 'medium' ); $medium_path = $medium_array[0]; return $medium_path; }
$id is the ID of the attachment
This can be really useful for plugins like WP-Choose-Thumb. With this function you can get the medium sized previews.
最新英語版: WordPress Codex » Function Reference/image downsize (最新版との差分)