get_the_attachment_link()

最后更新于:2021-11-27 01:02:35

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)

源文件

文件: gc-includes/deprecated.php

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

	if ( ('attachment' != $_post->post_type) || !$url = gc_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='https://docs.gechiui.com/functions/get_the_attachment_link/$url' title='$post_title'>$innerHTML</a>";
}