get_the_attachment_link

The timeline below displays how wordpress function get_the_attachment_link has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.5

/**
 * Retrieve HTML content of attachment image with link.
 *
 * @since 2.0.0
 * @deprecated 2.5.0 Use wp_get_attachment_link()
 * @see wp_get_attachment_link()
 *
 * @param int   $id       Optional. Post ID.
 * @param bool  $fullsize Optional. Whether to use full size image. Default false.
 * @param array $max_dims Optional. Max image dimensions.
 * @param bool $permalink Optional. Whether to include permalink to image. Default false.
 * @return string
 */
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>";
}

WordPress Version: 4.6

/**
 * Retrieve HTML content of attachment image with link.
 *
 * @since 2.0.0
 * @deprecated 2.5.0 Use wp_get_attachment_link()
 * @see wp_get_attachment_link()
 *
 * @param int $id Optional. Post ID.
 * @param bool $fullsize Optional, default is false. Whether to use full size image.
 * @param array $max_dims Optional. Max image dimensions.
 * @param bool $permalink Optional, default is false. Whether to include permalink to image.
 * @return string
 */
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>";
}

WordPress Version: 4.4

/**
 * Retrieve HTML content of attachment image with link.
 *
 * @since 2.0.0
 * @deprecated 2.5.0 Use wp_get_attachment_link()
 * @see wp_get_attachment_link()
 *
 * @param int $id Optional. Post ID.
 * @param bool $fullsize Optional, default is false. Whether to use full size image.
 * @param array $max_dims Optional. Max image dimensions.
 * @param bool $permalink Optional, default is false. Whether to include permalink to image.
 * @return string
 */
function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false)
{
    _deprecated_function(__FUNCTION__, '2.5', '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>";
}

WordPress Version: 3.7

/**
 * Retrieve HTML content of attachment image with link.
 *
 * @since 2.0.0
 * @deprecated 2.5.0
 * @deprecated Use wp_get_attachment_link()
 * @see wp_get_attachment_link()
 *
 * @param int $id Optional. Post ID.
 * @param bool $fullsize Optional, default is false. Whether to use full size image.
 * @param array $max_dims Optional. Max image dimensions.
 * @param bool $permalink Optional, default is false. Whether to include permalink to image.
 * @return string
 */
function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false)
{
    _deprecated_function(__FUNCTION__, '2.5', '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>";
}