wpseek.com
WordPress开发者和主题制作者的搜索引擎



get_the_attachment_link › WordPress Function

Since2.0.0
已弃用2.5.0
get_the_attachment_link ( $id = 0, $fullsize = false, $max_dims = false, $permalink = false )
参数: (4)
  • (int) $id Optional. Post ID.
    Required: No
    默认:
  • (bool) $fullsize Optional. Whether to use full size image. Default false.
    Required: No
    默认: false
  • (array) $max_dims Optional. Max image dimensions.
    Required: No
    默认: false
  • (bool) $permalink Optional. Whether to include permalink to image. Default false.
    Required: No
    默认: false
查看:
返回:
  • (string)
定义在:
文档:

Retrieve HTML content of attachment image with link.



源码

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>";
}