Make WordPress Core

Changeset 33669


Ignore:
Timestamp:
08/20/2015 08:31:34 PM (9 years ago)
Author:
wonderboymusic
Message:

In wp_get_attachment_link(), accept an id or WP_Post as the first parameter.

Props several27, DrewAPicture.
Fixes #33277.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post-template.php

    r32892 r33669  
    15561556 *
    15571557 * @since 2.5.0
     1558 * @since 4.4.0 The `$id` parameter can now accept either a post ID or `WP_Post` object.
    15581559 *
    15591560 * @param int|WP_Post  $id        Optional. Post ID or post object.
     
    15661567 */
    15671568function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false, $attr = '' ) {
    1568     $id = intval( $id );
    15691569    $_post = get_post( $id );
    15701570
     
    15781578        $link_text = $text;
    15791579    } elseif ( $size && 'none' != $size ) {
    1580         $link_text = wp_get_attachment_image( $id, $size, $icon, $attr );
     1580        $link_text = wp_get_attachment_image( $_post->ID, $size, $icon, $attr );
    15811581    } else {
    15821582        $link_text = '';
Note: See TracChangeset for help on using the changeset viewer.