Title: wp_get_attachment_image
Published: April 25, 2014
Last modified: August 20, 2026

---

# wp_get_attachment_image( int $attachment_id, string|int[] $size = ‘thumbnail’, bool $icon = false, string|array $attr = ” ): string

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#return)
 * [More Information](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#more-information)
    - [Usage](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#usage)
 * [Source](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#wp--skip-link--target)

Gets an HTML img element representing an image attachment.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#description)󠁿

While `$size` will accept an array, it is better to register a size with [add_image_size()](https://developer.wordpress.org/reference/functions/add_image_size/)
so that a cropped version is generated. It’s much more efficient than having to 
find the closest-sized image and then having the browser scale down the image.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#parameters)󠁿

 `$attachment_id`intrequired

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 `'thumbnail'`.

Default:`'thumbnail'`

`$icon`booloptional

Whether the image should be treated as an icon.

Default:`false`

`$attr`string|arrayoptional

Attributes for the image markup.

 * `src` string
 * Image attachment URL.
 * `class` string
 * CSS class name or space-separated list of classes.
    Default `attachment-$size_class
   size-$size_class`, where `$size_class` is the image size being requested.
 * `alt` string
 * Image description for the alt attribute.
 * `srcset` string
 * The `'srcset'` attribute value.
 * `sizes` string
 * The `'sizes'` attribute value.
 * `loading` string|false
 * The `'loading'` attribute value. Passing a value of false will result in the 
   attribute being omitted for the image.
    Default determined by [wp_get_loading_optimization_attributes()](https://developer.wordpress.org/reference/functions/wp_get_loading_optimization_attributes/).
 * `decoding` string
 * The `'decoding'` attribute value. Possible values are `'async'` (default), `'
   sync'`, or `'auto'`. Passing false or an empty string will result in the attribute
   being omitted.
 * `fetchpriority` string
 * The `'fetchpriority'` attribute value, whether `high`, `low`, or `auto`.
    Default
   determined by [wp_get_loading_optimization_attributes()](https://developer.wordpress.org/reference/functions/wp_get_loading_optimization_attributes/).

Default:`''`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#return)󠁿

 string HTML img element or empty string on failure.

## 󠀁[More Information](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#more-information)󠁿

### 󠀁[Usage](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#usage)󠁿

    ```php
    wp_get_attachment_image( $attachment_id, $size, $icon, $attr );
    ```

If the attachment is an image, the function returns an image at the specified size.
For other attachments, the function returns a media icon if the $icon parameter 
is set to true.

To get attachment IDs dynamically in a template, you can use `get_posts( array( '
post_type' => 'attachment' ) )`, etc.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#source)󠁿

    ```php
    function wp_get_attachment_image( $attachment_id, $size = 'thumbnail', $icon = false, $attr = '' ) {
    	$html  = '';
    	$image = wp_get_attachment_image_src( $attachment_id, $size, $icon );

    	if ( $image ) {
    		list( $src, $width, $height ) = $image;

    		$attachment = get_post( $attachment_id );
    		$size_class = $size;

    		if ( is_array( $size_class ) ) {
    			$size_class = implode( 'x', $size_class );
    		}

    		$default_attr = array(
    			'src'   => $src,
    			'class' => "attachment-$size_class size-$size_class",
    			'alt'   => trim( strip_tags( get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) ) ),
    		);

    		/**
    		 * Filters the context in which wp_get_attachment_image() is used.
    		 *
    		 * @since 6.3.0
    		 *
    		 * @param string $context The context. Default 'wp_get_attachment_image'.
    		 */
    		$context = apply_filters( 'wp_get_attachment_image_context', 'wp_get_attachment_image' );

    		$attr = wp_parse_args( $attr, $default_attr );

    		// Ensure that the `$width` doesn't overwrite an already valid user-provided width.
    		if ( ! isset( $attr['width'] ) || ! is_numeric( $attr['width'] ) ) {
    			$attr['width'] = $width;
    		}

    		// Ensure that the `$height` doesn't overwrite an already valid user-provided height.
    		if ( ! isset( $attr['height'] ) || ! is_numeric( $attr['height'] ) ) {
    			$attr['height'] = $height;
    		}

    		$loading_optimization_attr = wp_get_loading_optimization_attributes(
    			'img',
    			$attr,
    			$context
    		);

    		// Add loading optimization attributes if not available.
    		$attr = array_merge( $attr, $loading_optimization_attr );

    		// Omit the `decoding` attribute if the value is invalid according to the spec.
    		if ( empty( $attr['decoding'] ) || ! in_array( $attr['decoding'], array( 'async', 'sync', 'auto' ), true ) ) {
    			unset( $attr['decoding'] );
    		}

    		/*
    		 * If the default value of `lazy` for the `loading` attribute is overridden
    		 * to omit the attribute for this image, ensure it is not included.
    		 */
    		if ( isset( $attr['loading'] ) && ! $attr['loading'] ) {
    			unset( $attr['loading'] );
    		}

    		// If the `fetchpriority` attribute is overridden and set to false or an empty string.
    		if ( isset( $attr['fetchpriority'] ) && ! $attr['fetchpriority'] ) {
    			unset( $attr['fetchpriority'] );
    		}

    		// Generate 'srcset' and 'sizes' if not already present.
    		if ( empty( $attr['srcset'] ) ) {
    			$image_meta = wp_get_attachment_metadata( $attachment_id );

    			if ( is_array( $image_meta ) ) {
    				$size_array = array( absint( $width ), absint( $height ) );
    				$srcset     = wp_calculate_image_srcset( $size_array, $src, $image_meta, $attachment_id );
    				$sizes      = wp_calculate_image_sizes( $size_array, $src, $image_meta, $attachment_id );

    				if ( $srcset && ( $sizes || ! empty( $attr['sizes'] ) ) ) {
    					$attr['srcset'] = $srcset;

    					if ( empty( $attr['sizes'] ) ) {
    						$attr['sizes'] = $sizes;
    					}
    				}
    			}
    		}

    		/** This filter is documented in wp-includes/media.php */
    		$add_auto_sizes = apply_filters( 'wp_img_tag_add_auto_sizes', true );

    		// Adds 'auto' to the sizes attribute if applicable.
    		if (
    			$add_auto_sizes &&
    			isset( $attr['loading'] ) &&
    			'lazy' === $attr['loading'] &&
    			isset( $attr['sizes'] ) &&
    			! wp_sizes_attribute_includes_valid_auto( $attr['sizes'] )
    		) {
    			$attr['sizes'] = 'auto, ' . $attr['sizes'];
    		}

    		/**
    		 * Filters the list of attachment image attributes.
    		 *
    		 * @since 2.8.0
    		 * @since 6.8.2 The `$attr` array includes `width` and `height` attributes.
    		 *
    		 * @param string[]     $attr       Array of attribute values for the image markup, keyed by attribute name.
    		 *                                 See wp_get_attachment_image().
    		 * @param WP_Post      $attachment Image attachment post.
    		 * @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).
    		 */
    		$attr = apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment, $size );

    		if ( isset( $attr['width'] ) && is_numeric( $attr['width'] ) ) {
    			$width = absint( $attr['width'] );
    		}
    		if ( isset( $attr['height'] ) && is_numeric( $attr['height'] ) ) {
    			$height = absint( $attr['height'] );
    		}
    		unset( $attr['width'], $attr['height'] );

    		$attr     = array_map( 'esc_attr', $attr );
    		$hwstring = image_hwstring( $width, $height );
    		$html     = rtrim( "<img $hwstring" );

    		foreach ( $attr as $name => $value ) {
    			$html .= " $name=" . '"' . $value . '"';
    		}

    		$html .= ' />';
    	}

    	/**
    	 * Filters the HTML img element representing an image attachment.
    	 *
    	 * @since 5.6.0
    	 *
    	 * @param string       $html          HTML img element or empty string on failure.
    	 * @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.
    	 * @param string[]     $attr          Array of attribute values for the image markup, keyed by attribute name.
    	 *                                    See wp_get_attachment_image().
    	 */
    	return apply_filters( 'wp_get_attachment_image', $html, $attachment_id, $size, $icon, $attr );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/media.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/media.php#L1169)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/media.php#L1169-L1317)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#hooks)󠁿

 [apply_filters( ‘wp_get_attachment_image’, string $html, int $attachment_id, string|int[] $size, bool $icon, string[] $attr )](https://developer.wordpress.org/reference/hooks/wp_get_attachment_image/)

Filters the HTML img element representing an image attachment.

 [apply_filters( ‘wp_get_attachment_image_attributes’, string[] $attr, WP_Post $attachment, string|int[] $size )](https://developer.wordpress.org/reference/hooks/wp_get_attachment_image_attributes/)

Filters the list of attachment image attributes.

 [apply_filters( ‘wp_get_attachment_image_context’, string $context )](https://developer.wordpress.org/reference/hooks/wp_get_attachment_image_context/)

Filters the context in which [wp_get_attachment_image()](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/)
is used.

 [apply_filters( ‘wp_img_tag_add_auto_sizes’, boolean $enabled )](https://developer.wordpress.org/reference/hooks/wp_img_tag_add_auto_sizes/)

Filters whether auto-sizes for lazy loaded images is enabled.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_sizes_attribute_includes_valid_auto()](https://developer.wordpress.org/reference/functions/wp_sizes_attribute_includes_valid_auto/)`wp-includes/media.php` |

Checks whether the given ‘sizes’ attribute includes the ‘auto’ keyword as the first item in the list.

  | 
| [wp_get_loading_optimization_attributes()](https://developer.wordpress.org/reference/functions/wp_get_loading_optimization_attributes/)`wp-includes/media.php` |

Gets loading optimization attributes.

  | 
| [wp_calculate_image_srcset()](https://developer.wordpress.org/reference/functions/wp_calculate_image_srcset/)`wp-includes/media.php` |

A helper function to calculate the image sources to include in a ‘srcset’ attribute.

  | 
| [wp_calculate_image_sizes()](https://developer.wordpress.org/reference/functions/wp_calculate_image_sizes/)`wp-includes/media.php` |

Creates a ‘sizes’ attribute value for an image.

  | 
| [wp_get_attachment_image_src()](https://developer.wordpress.org/reference/functions/wp_get_attachment_image_src/)`wp-includes/media.php` |

Retrieves an image to represent an attachment.

  | 
| [image_hwstring()](https://developer.wordpress.org/reference/functions/image_hwstring/)`wp-includes/media.php` |

Retrieves width and height attributes using given width and height values.

  | 
| [wp_get_attachment_metadata()](https://developer.wordpress.org/reference/functions/wp_get_attachment_metadata/)`wp-includes/post.php` |

Retrieves attachment metadata for attachment ID.

  | 
| [wp_parse_args()](https://developer.wordpress.org/reference/functions/wp_parse_args/)`wp-includes/functions.php` |

Merges user defined arguments into defaults array.

  | 
| [absint()](https://developer.wordpress.org/reference/functions/absint/)`wp-includes/load.php` |

Converts a value to non-negative integer.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  | 
| [get_post_meta()](https://developer.wordpress.org/reference/functions/get_post_meta/)`wp-includes/post.php` |

Retrieves a post meta field for the given post ID.

  | 
| [get_post()](https://developer.wordpress.org/reference/functions/get_post/)`wp-includes/post.php` |

Retrieves post data given a post ID or post object.

  |

[Show 7 more](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#)

| Used by | Description | 
| [WP_Widget_Media_Image::render_media()](https://developer.wordpress.org/reference/classes/wp_widget_media_image/render_media/)`wp-includes/widgets/class-wp-widget-media-image.php` |

Render the media on the frontend.

  | 
| [get_custom_logo()](https://developer.wordpress.org/reference/functions/get_custom_logo/)`wp-includes/general-template.php` |

Returns a custom logo, linked to home unless the theme supports removing the link on the home page.

  | 
| [WP_Media_List_Table::column_title()](https://developer.wordpress.org/reference/classes/wp_media_list_table/column_title/)`wp-admin/includes/class-wp-media-list-table.php` |

Handles the title column output.

  | 
| [_wp_post_thumbnail_html()](https://developer.wordpress.org/reference/functions/_wp_post_thumbnail_html/)`wp-admin/includes/post.php` |

Returns HTML for the post thumbnail meta box.

  | 
| [WP_Comments_List_Table::column_response()](https://developer.wordpress.org/reference/classes/wp_comments_list_table/column_response/)`wp-admin/includes/class-wp-comments-list-table.php` |

Outputs the response column.

  | 
| [get_the_post_thumbnail()](https://developer.wordpress.org/reference/functions/get_the_post_thumbnail/)`wp-includes/post-thumbnail-template.php` |

Retrieves the post thumbnail.

  | 
| [wp_get_attachment_link()](https://developer.wordpress.org/reference/functions/wp_get_attachment_link/)`wp-includes/post-template.php` |

Retrieves an attachment page link using an image or icon, if possible.

  | 
| [gallery_shortcode()](https://developer.wordpress.org/reference/functions/gallery_shortcode/)`wp-includes/media.php` |

Builds the Gallery shortcode output.

  | 
| [set_post_thumbnail()](https://developer.wordpress.org/reference/functions/set_post_thumbnail/)`wp-includes/post.php` |

Sets the post thumbnail (featured image) for the given post.

  |

[Show 4 more](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.1.0](https://developer.wordpress.org/reference/since/6.1.0/) | The `$decoding` attribute was added. | 
| [5.5.0](https://developer.wordpress.org/reference/since/5.5.0/) | The `$loading` attribute was added. | 
| [4.4.0](https://developer.wordpress.org/reference/since/4.4.0/) | The `$srcset` and `$sizes` attributes were added. | 
| [2.5.0](https://developer.wordpress.org/reference/since/2.5.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 6 content](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#comment-content-1579)
 2.    [Rinku Y](https://profiles.wordpress.org/rinkuyadav999/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/#comment-1579)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_attachment_image%2F%23comment-1579)
     Vote results for this note: 9[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_attachment_image%2F%23comment-1579)
 4.  wp_get_attachment_image function can accept four values as you can see:
 5.      ```php
         wp_get_attachment_image ( int $attachment_id, string|array $size = 'thumbnail', bool $icon = false, string|array $attr = '' )
         ```
     
 6.  So i always use:
 7.      ```php
         <?php echo wp_get_attachment_image( get_the_ID(), array('700', '600'), "", array( "class" => "img-responsive" ) );  ?>
         ```
     
 8.  Note: we can simply use **[get_the_ID()](https://developer.wordpress.org/reference/functions/get_the_id/)**
     to pass id of active post. and here **700 is width** and **600 is height** of 
     attachment image. we can also pass our class as **array( “class” => “img-responsive”)**.
 9.   * Why [get_the_ID()](https://developer.wordpress.org/reference/functions/get_the_id/)?
        It should be an attachment ID, no a current post ID.
      * [oborvanec](https://profiles.wordpress.org/oborvanec/) [7 years ago](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/#comment-3557)
      * Absolutely agree with @oborvanec, this code above is wrong and will not work.
        Using **[get_the_ID()](https://developer.wordpress.org/reference/functions/get_the_id/)**
        will not get you the correct value — you need to get post _thumbnail ID_ not
        the page/post ID. This example above should be changed to: **[get_post_thumbnail_id()](https://developer.wordpress.org/reference/functions/get_post_thumbnail_id/)**
      * [onetrev](https://profiles.wordpress.org/onetrev/) [6 years ago](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/#comment-3859)
 10.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_attachment_image%2F%3Freplytocom%3D1579%23feedback-editor-1579)
 11.  [Skip to note 7 content](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#comment-content-2430)
 12.   [tazotodua](https://profiles.wordpress.org/tazotodua/)  [  9 years ago  ](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/#comment-2430)
 13. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_attachment_image%2F%23comment-2430)
     Vote results for this note: 7[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_attachment_image%2F%23comment-2430)
 14. default call returns like this:
 15.     ```php
         <img width="150" height="150" src="http://example.com/wp-content/uploads/2017/11/image-xyz-150x150.jpg&quot; class="attachment-thumbnail size-thumbnail" alt="" srcset="http://example.com/wp-content/uploads/2017/11/image-xyz-150x150.jpg 150w, http://example.com/wp-content/uploads/2017/11/image-xyz-50x50.jpg 50w" sizes="(max-width: 150px) 100vw, 150px" />
         ```
     
 16.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_attachment_image%2F%3Freplytocom%3D2430%23feedback-editor-2430)
 17.  [Skip to note 8 content](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#comment-content-350)
 18.   [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/#comment-350)
 19. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_attachment_image%2F%23comment-350)
     Vote results for this note: 2[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_attachment_image%2F%23comment-350)
 20. To display all of the images and titles attached to a certain page and display
     them as a list of bullets you can use the following:
 21.     ```php
         <ul>
         	<?php if ( have_posts() ) : while ( have_posts() ) : the_post();
     
         		$attachments = get_posts( array(
         			'post_type'   => 'attachment',
         			'numberposts' => -1,
         			'post_status' => null,
         			'post_parent' => $post->ID
         		) );
     
         		if ( $attachments ) {
         			foreach ( $attachments as $attachment ) {
         				?>
         				<li><?php echo wp_get_attachment_image( $attachment->ID, 'full' ); ?>
         					<p><?php echo apply_filters( 'the_title', $attachment->post_title ); ?></p>
         				</li>
         				<?php
         			}
         		}
         	endwhile; endif; ?>
         </ul>
         ```
     
 22.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_attachment_image%2F%3Freplytocom%3D350%23feedback-editor-350)
 23.  [Skip to note 9 content](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#comment-content-3273)
 24.   Anonymous User  [  7 years ago  ](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/#comment-3273)
 25. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_attachment_image%2F%23comment-3273)
     Vote results for this note: 1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_attachment_image%2F%23comment-3273)
 26. `wp_get_attachment_image` is the good way to receive image from theme/plugin options.
     In order to fetch the image that was upload from custom option, do this:
 27.     ```php
         echo wp_get_attachment_image(
         	get_theme_mod( $option_id_in_string )
         );
         ```
     
 28.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_attachment_image%2F%3Freplytocom%3D3273%23feedback-editor-3273)
 29.  [Skip to note 10 content](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/?output_format=md#comment-content-7300)
 30.   [shanemac10](https://profiles.wordpress.org/shanemac10/)  [  2 years ago  ](https://developer.wordpress.org/reference/functions/wp_get_attachment_image/#comment-7300)
 31. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_attachment_image%2F%23comment-7300)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_attachment_image%2F%23comment-7300)
 32. To force an image to display the full size file, you can pass a single space `''`
     as the `srcset` attribute. Note, you cannot pass an empty string, because the 
     attribute value is tested with `empty()`, so an empty string will trigger the 
     default `srcset` attribute to be built.
 33.     ```php
         wp_get_attachment_image( $attachment_id, 'full', false, [ 'srcset' => ' ' ] );
         ```
     
 34.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_attachment_image%2F%3Freplytocom%3D7300%23feedback-editor-7300)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_attachment_image%2F)
before being able to contribute a note or feedback.