使用的第二个参数wp_get_attachment_image_src()
: $size
.
$att = wp_get_attachment_image_src( $att_ID, \'large-thumb\' );
或
$att = wp_get_attachment_image_src( $att_ID, array ( 900, 300 ) );
大小传递给
image_downsize()
还有
image_get_intermediate_size()
. 如果
$size
是一个数组WordPress将在现有图像中搜索最佳匹配:
// from wp-includes/media.php::image_get_intermediate_size()
// get the best one for a specified set of dimensions
if ( is_array($size) && !empty($imagedata[\'sizes\']) ) {
foreach ( $imagedata[\'sizes\'] as $_size => $data ) {
// already cropped to width or height; so use this size
if ( ( $data[\'width\'] == $size[0] && $data[\'height\'] <= $size[1] ) || ( $data[\'height\'] == $size[1] && $data[\'width\'] <= $size[0] ) ) {
$file = $data[\'file\'];
list($width, $height) = image_constrain_size_for_editor( $data[\'width\'], $data[\'height\'], $size );
return compact( \'file\', \'width\', \'height\' );
}