Nhận URL của một tệp đính kèm hình ảnh. ID đính kèm hình ảnh. Kích cỡ hình. Chấp nhận bất kỳ tên kích thước hình ảnh đã đăng ký hoặc một mảng có giá trị chiều rộng và chiều cao trong pixel [theo thứ tự đó]. Mặc định Mặc định: Liệu hình ảnh nên được coi là một biểu tượng. Mặc định: WP_GET_ATTACHMENT_IMAGE_URL [int & nbsp; $ bottomment_id, String | int [] & nbsp; $ size & nbsp; = & nbsp; 'Hình thu nhỏ', bool & nbsp;int $attachment_id, string|int[] $size = 'thumbnail', bool $icon = false ]: string|false
$attachment_id
Intrequiredint Required
$size
chuỗi | int [] tùy chọnstring|int[] Optional'thumbnail'
.'thumbnail'
$icon
BOOLOPTIONALbool Optionalfalse
Chuỗi | URL đính kèm sai hoặc sai nếu không có hình ảnh. Nếu $size
không khớp với bất kỳ kích thước hình ảnh đã đăng ký nào, URL hình ảnh gốc sẽ được trả về. Attachment URL or false if no image is available. If $size
does not match any registered image size, the original image URL will be returned.
Tệp: wp-includes/media.php
. Xem tất cả các tài liệu tham khảo
function wp_get_attachment_image_url[ $attachment_id, $size = 'thumbnail', $icon = false ] {
$image = wp_get_attachment_image_src[ $attachment_id, $size, $icon ];
return isset[ $image[0] ] ? $image[0] : false;
}
Xem trên Tracview trên GitHub View on GitHub
4.4.0 | Được giới thiệu. |
Lấy một hình ảnh để đại diện cho một tệp đính kèm. ID đính kèm hình ảnh.WP_GET_ATTACHMENT_IMAGE_SRC [int & nbsp; $ bottomment_id, String | int [] & nbsp; $ size & nbsp; = & nbsp; 'Hình thu nhỏ', bool & nbsp;int $attachment_id, string|int[] $size = 'thumbnail', bool $icon = false ]: array|false
$attachment_id
Intrequiredint
Required
$size
chuỗi | int [] tùy chọnstring|int[] Optional Kích cỡ hình. Chấp nhận bất kỳ tên kích thước hình ảnh đã đăng ký hoặc một mảng có giá trị chiều rộng và chiều cao trong pixel [theo thứ tự đó]. Mặc định 'thumbnail'
.
Mặc định: 'thumbnail'
$icon
BOOLOPTIONALbool OptionalLiệu hình ảnh có trở lại biểu tượng loại MIME hay không.
Mặc định: false
Mảng | Mảng sai của dữ liệu hình ảnh hoặc Boolean Sai nếu không có hình ảnh. Array of image data, or boolean false if no image is available.
- sợi dây
URL nguồn hình ảnh.
6intintfunction wp_get_attachment_image_src[ $attachment_id, $size = 'thumbnail', $icon = false ] { // Get a thumbnail or intermediate image if there is one. $image = image_downsize[ $attachment_id, $size ]; if [ ! $image ] { $src = false; if [ $icon ] { $src = wp_mime_type_icon[ $attachment_id ]; if [ $src ] { /** This filter is documented in wp-includes/post.php */ $icon_dir = apply_filters[ 'icon_dir', ABSPATH . WPINC . '/images/media' ]; $src_file = $icon_dir . '/' . wp_basename[ $src ]; list[ $width, $height ] = wp_getimagesize[ $src_file ]; } } if [ $src && $width && $height ] { $image = array[ $src, $width, $height, false ]; } } /** * Filters the attachment image source result. * * @since 4.3.0 * * @param array|false $image { * Array of image data, or boolean false if no image is available. * * @type string $0 Image source URL. * @type int $1 Image width in pixels. * @type int $2 Image height in pixels. * @type bool $3 Whether the image is a resized image. * } * @param int $attachment_id Image attachment ID. * @param string|int[] $size Requested image size. Can be any registered image size name, or * an array of width and height values in pixels [in that order]. * @param bool $icon Whether the image should be treated as an icon. */ return apply_filters[ 'wp_get_attachment_image_src', $image, $attachment_id, $size, $icon ]; }
Chiều rộng hình ảnh tính bằng pixel.
7intintfunction wp_get_attachment_image_src[ $attachment_id, $size = 'thumbnail', $icon = false ] { // Get a thumbnail or intermediate image if there is one. $image = image_downsize[ $attachment_id, $size ]; if [ ! $image ] { $src = false; if [ $icon ] { $src = wp_mime_type_icon[ $attachment_id ]; if [ $src ] { /** This filter is documented in wp-includes/post.php */ $icon_dir = apply_filters[ 'icon_dir', ABSPATH . WPINC . '/images/media' ]; $src_file = $icon_dir . '/' . wp_basename[ $src ]; list[ $width, $height ] = wp_getimagesize[ $src_file ]; } } if [ $src && $width && $height ] { $image = array[ $src, $width, $height, false ]; } } /** * Filters the attachment image source result. * * @since 4.3.0 * * @param array|false $image { * Array of image data, or boolean false if no image is available. * * @type string $0 Image source URL. * @type int $1 Image width in pixels. * @type int $2 Image height in pixels. * @type bool $3 Whether the image is a resized image. * } * @param int $attachment_id Image attachment ID. * @param string|int[] $size Requested image size. Can be any registered image size name, or * an array of width and height values in pixels [in that order]. * @param bool $icon Whether the image should be treated as an icon. */ return apply_filters[ 'wp_get_attachment_image_src', $image, $attachment_id, $size, $icon ]; }
Chiều cao hình ảnh trong pixel.
8boolboolfunction wp_get_attachment_image_src[ $attachment_id, $size = 'thumbnail', $icon = false ] { // Get a thumbnail or intermediate image if there is one. $image = image_downsize[ $attachment_id, $size ]; if [ ! $image ] { $src = false; if [ $icon ] { $src = wp_mime_type_icon[ $attachment_id ]; if [ $src ] { /** This filter is documented in wp-includes/post.php */ $icon_dir = apply_filters[ 'icon_dir', ABSPATH . WPINC . '/images/media' ]; $src_file = $icon_dir . '/' . wp_basename[ $src ]; list[ $width, $height ] = wp_getimagesize[ $src_file ]; } } if [ $src && $width && $height ] { $image = array[ $src, $width, $height, false ]; } } /** * Filters the attachment image source result. * * @since 4.3.0 * * @param array|false $image { * Array of image data, or boolean false if no image is available. * * @type string $0 Image source URL. * @type int $1 Image width in pixels. * @type int $2 Image height in pixels. * @type bool $3 Whether the image is a resized image. * } * @param int $attachment_id Image attachment ID. * @param string|int[] $size Requested image size. Can be any registered image size name, or * an array of width and height values in pixels [in that order]. * @param bool $icon Whether the image should be treated as an icon. */ return apply_filters[ 'wp_get_attachment_image_src', $image, $attachment_id, $size, $icon ]; }
Cho dù hình ảnh là một hình ảnh kích thước.
Tệp: wp-includes/media.php
. Xem tất cả các tài liệu tham khảo
function wp_get_attachment_image_src[ $attachment_id, $size = 'thumbnail', $icon = false ] {
// Get a thumbnail or intermediate image if there is one.
$image = image_downsize[ $attachment_id, $size ];
if [ ! $image ] {
$src = false;
if [ $icon ] {
$src = wp_mime_type_icon[ $attachment_id ];
if [ $src ] {
/** This filter is documented in wp-includes/post.php */
$icon_dir = apply_filters[ 'icon_dir', ABSPATH . WPINC . '/images/media' ];
$src_file = $icon_dir . '/' . wp_basename[ $src ];
list[ $width, $height ] = wp_getimagesize[ $src_file ];
}
}
if [ $src && $width && $height ] {
$image = array[ $src, $width, $height, false ];
}
}
/**
* Filters the attachment image source result.
*
* @since 4.3.0
*
* @param array|false $image {
* Array of image data, or boolean false if no image is available.
*
* @type string $0 Image source URL.
* @type int $1 Image width in pixels.
* @type int $2 Image height in pixels.
* @type bool $3 Whether the image is a resized image.
* }
* @param int $attachment_id Image attachment ID.
* @param string|int[] $size Requested image size. Can be any registered image size name, or
* an array of width and height values in pixels [in that order].
* @param bool $icon Whether the image should be treated as an icon.
*/
return apply_filters[ 'wp_get_attachment_image_src', $image, $attachment_id, $size, $icon ];
}
Xem trên Tracview trên GitHub View on GitHub
Lọc đường dẫn thư mục biểu tượng.
Ứng dụng_filters ['wp_get_attachment_image_src', mảng | false $ Image, int $ đính kèm_id, chuỗi | int [] $ size, bool $ icon][ 'wp_get_attachment_image_src', array|false $image, int $attachment_id, string|int[] $size, bool $icon ]Lọc kết quả nguồn hình ảnh đính kèm.
2.5.0 | Được giới thiệu. |