From f804d9a91d839093cbe78aa356a5a427b5f7b8bf Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 20 Aug 2015 20:31:34 +0000 Subject: [PATCH] In `wp_get_attachment_link()`, accept an `id` or `WP_Post` as the first parameter. Props several27, DrewAPicture. Fixes #33277. git-svn-id: https://develop.svn.wordpress.org/trunk@33669 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/post-template.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/post-template.php b/src/wp-includes/post-template.php index 1b4901cc92..b85a77339e 100644 --- a/src/wp-includes/post-template.php +++ b/src/wp-includes/post-template.php @@ -1555,6 +1555,7 @@ function the_attachment_link( $id = 0, $fullsize = false, $deprecated = false, $ * Retrieve an attachment page link using an image or icon, if possible. * * @since 2.5.0 + * @since 4.4.0 The `$id` parameter can now accept either a post ID or `WP_Post` object. * * @param int|WP_Post $id Optional. Post ID or post object. * @param string $size Optional, default is 'thumbnail'. Size of image, either array or string. @@ -1565,7 +1566,6 @@ function the_attachment_link( $id = 0, $fullsize = false, $deprecated = false, $ * @return string HTML content. */ function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false, $attr = '' ) { - $id = intval( $id ); $_post = get_post( $id ); if ( empty( $_post ) || ( 'attachment' != $_post->post_type ) || ! $url = wp_get_attachment_url( $_post->ID ) ) @@ -1577,7 +1577,7 @@ function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = fals if ( $text ) { $link_text = $text; } elseif ( $size && 'none' != $size ) { - $link_text = wp_get_attachment_image( $id, $size, $icon, $attr ); + $link_text = wp_get_attachment_image( $_post->ID, $size, $icon, $attr ); } else { $link_text = ''; }