钩子文档

{$adjacent}_image_link

💡 云策文档标注

概述

此文档介绍了一个用于过滤相邻图像链接的WordPress钩子,钩子名称基于$adjacent参数动态生成,支持'next'或'previous'类型。它允许开发者自定义相邻图像链接的HTML输出。

关键要点

  • 钩子名称:{$adjacent}_image_link,其中$adjacent可以是'next'或'previous',对应具体钩子如next_image_link和previous_image_link。
  • 参数:包括$output(HTML标记)、$attachment_id(附件ID)、$size(图像尺寸)和$text(链接文本)。
  • 用途:主要用于get_adjacent_image_link()函数中,以修改相邻图像链接的渲染。
  • 版本历史:自WordPress 3.5.0版本引入。

📄 原文内容

Filters the adjacent image link.

Description

The dynamic portion of the hook name, $adjacent, refers to the type of adjacency, either ‘next’, or ‘previous’.

Possible hook names include:

  • next_image_link
  • previous_image_link

Parameters

$outputstring
Adjacent image HTML markup.
$attachment_idint
Attachment ID
$sizestring|int[]
Requested image size. Can be any registered image size name, or an array of width and height values in pixels (in that order).
$textstring
Link text.

Source

return apply_filters( "{$adjacent}_image_link", $output, $attachment_id, $size, $text );

Changelog

Version Description
3.5.0 Introduced.