WordPress at a glance

wp_get_attachment_image_url() WP 1.0

Get the URL of an image attachment.

✈ 1 time = 0.002972s = very slow | 50000 times = 10.29s = slow PHP 7.1.5, WP 4.8.1

No Hooks.

Return

String/false. Attachment URL or false if no image is available.

Usage

wp_get_attachment_image_url( $attachment_id, $size, $icon );
$attachment_id(int) (required)
Image attachment ID.
$size(string/array)
Image size to retrieve. Accepts any valid image size, or an array of width and height values in pixels (in that order).
Default: 'thumbnail'
$icon(true/false)
Whether the image should be treated as an icon.
Default: false

Code of wp_get_attachment_image_url: wp-includes/media.php VER 4.9.8

<?php
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;
}

Related Functions

From tag: Thumbnail (images)

More from tag: Link (URL)

More from category: Images

No comments
    Hello, !     Log In . Register