Make WordPress Core

Changeset 4682


Ignore:
Timestamp:
01/05/2007 08:54:55 PM (19 years ago)
Author:
ryan
Message:

wp_get_attachment_thumb_url() fix from mdawaffe. fixes #3520

Location:
trunk/wp-includes
Files:
2 edited

Legend:

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

    r4671 r4682  
    379379        return false;
    380380
    381     if ( !$src = get_attachment_icon_src( $id, $fullsize ) )
     381    if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) )
    382382        return false;
    383383
     
    416416function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) {
    417417    $id = (int) $id;
    418 
    419     if ( $innerHTML = get_attachment_icon($id, $fullsize, $max_dims))
     418    if ( !$post = & get_post($id) )
     419        return false;
     420
     421    if ( $innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims))
    420422        return $innerHTML;
    421423
    422     $post = & get_post($id);
    423424
    424425    $innerHTML = attribute_escape($post->post_title);
  • trunk/wp-includes/post.php

    r4675 r4682  
    14031403function wp_get_attachment_metadata( $post_id, $unfiltered = false ) {
    14041404    $post_id = (int) $post_id;
    1405 
    1406     $data = get_post_meta( $post_id, '_wp_attachment_metadata', true );
     1405    if ( !$post =& get_post( $post_id ) )
     1406        return false;
     1407
     1408    $data = get_post_meta( $post->ID, '_wp_attachment_metadata', true );
    14071409    if ( $unfiltered )
    14081410        return $data;
    1409     return apply_filters( 'wp_get_attachment_metadata', $data, $post_id );
     1411    return apply_filters( 'wp_get_attachment_metadata', $data, $post->ID );
    14101412}
    14111413
    14121414function wp_update_attachment_metadata( $post_id, $data ) {
    14131415    $post_id = (int) $post_id;
    1414     if ( !get_post( $post_id ) )
    1415         return false;
    1416 
    1417     $old_data = wp_get_attachment_metadata( $post_id, true );
    1418 
    1419     $data = apply_filters( 'wp_update_attachment_metadata', $data, $post_id );
     1416    if ( !$post =& get_post( $post_id ) )
     1417        return false;
     1418
     1419    $old_data = wp_get_attachment_metadata( $post->ID, true );
     1420
     1421    $data = apply_filters( 'wp_update_attachment_metadata', $data, $post->ID );
    14201422
    14211423    if ( $old_data )
    1422         return update_post_meta( $post_id, '_wp_attachment_metadata', $data, $old_data );
     1424        return update_post_meta( $post->ID, '_wp_attachment_metadata', $data, $old_data );
    14231425    else
    1424         return add_post_meta( $post_id, '_wp_attachment_metadata', $data );
     1426        return add_post_meta( $post->ID, '_wp_attachment_metadata', $data );
    14251427}
    14261428
     
    14301432        return false;
    14311433
    1432     $url = get_the_guid( $post_id );
     1434    $url = get_the_guid( $post->ID );
    14331435
    14341436    if ( 'attachment' != $post->post_type || !$url )
    14351437        return false;
    14361438
    1437     return apply_filters( 'wp_get_attachment_url', $url, $post_id );
    1438 }
    1439 
    1440 function wp_get_attachment_thumb_file( $post_id ) {
     1439    return apply_filters( 'wp_get_attachment_url', $url, $post->ID );
     1440}
     1441
     1442function wp_get_attachment_thumb_file( $post_id = 0 ) {
    14411443    $post_id = (int) $post_id;
    1442     if ( !$imagedata = wp_get_attachment_metadata( $post_id ) )
    1443         return false;
    1444 
    1445     $file = get_attached_file( $post_id );
     1444    if ( !$post =& get_post( $post_id ) )
     1445        return false;
     1446    if ( !$imagedata = wp_get_attachment_metadata( $post->ID ) )
     1447        return false;
     1448
     1449    $file = get_attached_file( $post->ID );
    14461450
    14471451    if ( !empty($imagedata['thumb']) && ($thumbfile = str_replace(basename($file), $imagedata['thumb'], $file)) && file_exists($thumbfile) )
    1448         return apply_filters( 'wp_get_attachment_thumb_file', $thumbfile, $post_id );
     1452        return apply_filters( 'wp_get_attachment_thumb_file', $thumbfile, $post->ID );
    14491453    return false;
    14501454}
     
    14521456function wp_get_attachment_thumb_url( $post_id = 0 ) {
    14531457    $post_id = (int) $post_id;
    1454     if ( !$url = wp_get_attachment_url( $post_id ) )
    1455         return false;
    1456 
    1457     if ( !$thumb = wp_get_attachment_thumb_file( $post_id ) )
     1458    if ( !$post =& get_post( $post_id ) )
     1459        return false;
     1460    if ( !$url = wp_get_attachment_url( $post->ID ) )
     1461        return false;
     1462
     1463    if ( !$thumb = wp_get_attachment_thumb_file( $post->ID ) )
    14581464        return false;
    14591465
    14601466    $url = str_replace(basename($url), basename($thumb), $url);
    14611467
    1462     return apply_filters( 'wp_get_attachment_thumb_url', $url, $post_id );
     1468    return apply_filters( 'wp_get_attachment_thumb_url', $url, $post->ID );
    14631469}
    14641470
Note: See TracChangeset for help on using the changeset viewer.