Title: wp_get_attachment_image_context
Published: August 8, 2023
Last modified: May 20, 2026

---

# apply_filters( ‘wp_get_attachment_image_context’, string $context )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/hooks/wp_get_attachment_image_context/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/wp_get_attachment_image_context/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/wp_get_attachment_image_context/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/wp_get_attachment_image_context/?output_format=md#changelog)

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

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

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

 `$context`string

The context. Default `'wp_get_attachment_image'`.

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

    ```php
    $context = apply_filters( 'wp_get_attachment_image_context', 'wp_get_attachment_image' );
    ```

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

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

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

Gets an HTML img element representing an image attachment.

  |

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

| Version | Description | 
| [6.3.0](https://developer.wordpress.org/reference/since/6.3.0/) | Introduced. |

## User Contributed Notes

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