get_the_attachment_link() - WordPress 函数参考中文文档

返回介绍

get_the_attachment_link()

发布于 2017-09-11 字数2495 浏览 942 评论 0

Warning: This function has been deprecated. Use wp_get_attachment_link() instead.

get_the_attachment_link( int $id,  bool $fullsize = false,  array $max_dims = false,  bool $permalink = false )

Retrieve HTML content of attachment image with link.


描述


参数

$id

(int)
(Optional)
Post ID.

$fullsize

(bool)
(Optional)
Whether to use full size image.

Default value: false

$max_dims

(array)
(Optional)
Max image dimensions.

Default value: false

$permalink

(bool)
(Optional)
Whether to include permalink to image.

Default value: false


返回值

(string)


源代码

File: wp-includes/deprecated.php

function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) {
	_deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_link()' );
	$id = (int) $id;
	$_post = get_post($id);

	if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) )
		return __('Missing Attachment');

	if ( $permalink )
		$url = get_attachment_link($_post->ID);

	$post_title = esc_attr($_post->post_title);

	$innerHTML = get_attachment_innerHTML($_post->ID, $fullsize, $max_dims);
	return "<a href='$url' title='$post_title'>$innerHTML</a>";
}

更新日志

Version 描述
2.5.0 Use wp_get_attachment_link()
2.0.0 Introduced.

相关函数

Uses

  • wp-includes/l10n.php:
    __()
  • wp-includes/formatting.php:
    esc_attr()
  • wp-includes/deprecated.php:
    get_attachment_innerHTML()
  • wp-includes/functions.php:
    _deprecated_function()
  • wp-includes/link-template.php:
    get_attachment_link()
  • wp-includes/post.php:
    wp_get_attachment_url()
  • wp-includes/post.php:
    get_post()
  • Show 2 more uses
    Hide more uses


User Contributed Notes

上一篇:get_the_archive_title()

下一篇:get_the_author()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!