get_the_attachment_link() WP 2.0.0
Deprecated from version 2.5.0. It is no longer supported and can be removed in future releases. Use wp_get_attachment_link() instead.╳
Retrieve HTML content of attachment image with link.
No Hooks.
Return
String
. Null. Nothing.
Usage
get_the_attachment_link( $id, $fullsize, $max_dims, $permalink );
- $id(int)
- Post ID.
- $fullsize(true|false)
- Whether to use full size image.
Default: false - $max_dims(array)
- Max image dimensions.
- $permalink(true|false)
- Whether to include permalink to image.
Default: false
Notes
- See: wp_get_attachment_link()
Changelog
Since 2.0.0 | Introduced. | |
Deprecated Since 2.5.0 | Use wp_get_attachment_link() |
Code of get_the_attachment_link() get the attachment link WP 5.7
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>";
}