get_previous_image_link()
云策文档标注
概述
get_previous_image_link() 函数用于获取同一父文章中的前一张图片链接。它基于 get_adjacent_image_link() 实现,是 WordPress 媒体处理功能的一部分。
关键要点
- 函数返回同一父文章中的前一张图片链接的 HTML 标记。
- 接受两个可选参数:$size(图片尺寸,默认为 'thumbnail')和 $text(链接文本,默认为 false)。
- 内部调用 get_adjacent_image_link() 函数,传递 true 参数以获取前一张图片。
- 自 WordPress 5.8.0 版本引入。
代码示例
function get_previous_image_link( $size = 'thumbnail', $text = false ) {
return get_adjacent_image_link( true, $size, $text );
}
原文内容
Gets the previous image link that has the same post parent.
Description
See also
Parameters
$sizestring|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'. $textstring|falseoptional-
Link text.
Default:
false
Source
function get_previous_image_link( $size = 'thumbnail', $text = false ) {
return get_adjacent_image_link( true, $size, $text );
}
Changelog
| Version | Description |
|---|---|
| 5.8.0 | Introduced. |