钩子文档

wp_get_attachment_image_context

💡 云策文档标注

概述

wp_get_attachment_image_context 是一个 WordPress 过滤器,用于修改 wp_get_attachment_image() 函数使用的上下文参数。它允许开发者在获取附件图像时自定义上下文字符串。

关键要点

  • 这是一个过滤器 Hook,名称为 wp_get_attachment_image_context
  • 默认上下文为 'wp_get_attachment_image',可通过此过滤器进行修改
  • 在 WordPress 6.3.0 版本中引入
  • 与 wp_get_attachment_image() 函数相关,用于获取图像附件的 HTML img 元素

代码示例

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

📄 原文内容

Filters the context in which wp_get_attachment_image() is used.

Parameters

$contextstring
The context. Default 'wp_get_attachment_image'.

Source

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

Changelog

Version Description
6.3.0 Introduced.