wp_get_attachment_image_src
wp_get_attachment_image_src( int $attachment_id, string|int[] $size = 'thumbnail', bool $icon = false )
Retrieves an image to represent an attachment.
Parameters
- $attachment_id – (int) (Required) Image attachment ID.
- $size – (string|int[]) (Optional) Image size. Accepts any registered image size name, or an array of width and height values in pixels (in that order).
- Default value: ‘thumbnail’
- $icon – (bool) (Optional) Whether the image should fall back to a mime type icon.Default value: false
wordpress wp_get_attachment_image_src
$image_attributes = wp_get_attachment_image_src( $attachment_id = 8 ); if ( $image_attributes ) : ?> <img src="<?php echo $image_attributes[0]; ?>" width="<?php echo $image_attributes[1]; ?>" height="<?php echo $image_attributes[2]; ?>" /> <?php endif; ?>
wp get attachment image src
To get original size URL image in the function wp_get_attachment_image_src use
$img_atts = wp_get_attachment_image_src($IMG_ID, 'full'); <img src="<?php echo $img_atts[0]; ?>"
WP have 3 default sizes as 100×100 thumbnail, 300×300 medium and 800×800 large.
$image_id=get_post_thumbnail_id(); $image_url = wp_get_attachment_image_src($image_id,'img-polaroid'); $image_url=$image_url[0];