wp_get_attachment_thumb_url() fix from mdawaffe. fixes #3520
git-svn-id: https://develop.svn.wordpress.org/trunk@4682 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
4f8f53b7b3
commit
ac7d4b46cc
@ -378,7 +378,7 @@ function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) {
|
|||||||
if ( !$post = & get_post($id) )
|
if ( !$post = & get_post($id) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( !$src = get_attachment_icon_src( $id, $fullsize ) )
|
if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
list($src, $src_file) = $src;
|
list($src, $src_file) = $src;
|
||||||
@ -415,11 +415,12 @@ function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) {
|
|||||||
|
|
||||||
function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) {
|
function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) {
|
||||||
$id = (int) $id;
|
$id = (int) $id;
|
||||||
|
if ( !$post = & get_post($id) )
|
||||||
|
return false;
|
||||||
|
|
||||||
if ( $innerHTML = get_attachment_icon($id, $fullsize, $max_dims))
|
if ( $innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims))
|
||||||
return $innerHTML;
|
return $innerHTML;
|
||||||
|
|
||||||
$post = & get_post($id);
|
|
||||||
|
|
||||||
$innerHTML = attribute_escape($post->post_title);
|
$innerHTML = attribute_escape($post->post_title);
|
||||||
|
|
||||||
|
@ -1402,26 +1402,28 @@ function wp_delete_attachment($postid) {
|
|||||||
|
|
||||||
function wp_get_attachment_metadata( $post_id, $unfiltered = false ) {
|
function wp_get_attachment_metadata( $post_id, $unfiltered = false ) {
|
||||||
$post_id = (int) $post_id;
|
$post_id = (int) $post_id;
|
||||||
|
if ( !$post =& get_post( $post_id ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
$data = get_post_meta( $post_id, '_wp_attachment_metadata', true );
|
$data = get_post_meta( $post->ID, '_wp_attachment_metadata', true );
|
||||||
if ( $unfiltered )
|
if ( $unfiltered )
|
||||||
return $data;
|
return $data;
|
||||||
return apply_filters( 'wp_get_attachment_metadata', $data, $post_id );
|
return apply_filters( 'wp_get_attachment_metadata', $data, $post->ID );
|
||||||
}
|
}
|
||||||
|
|
||||||
function wp_update_attachment_metadata( $post_id, $data ) {
|
function wp_update_attachment_metadata( $post_id, $data ) {
|
||||||
$post_id = (int) $post_id;
|
$post_id = (int) $post_id;
|
||||||
if ( !get_post( $post_id ) )
|
if ( !$post =& get_post( $post_id ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$old_data = wp_get_attachment_metadata( $post_id, true );
|
$old_data = wp_get_attachment_metadata( $post->ID, true );
|
||||||
|
|
||||||
$data = apply_filters( 'wp_update_attachment_metadata', $data, $post_id );
|
$data = apply_filters( 'wp_update_attachment_metadata', $data, $post->ID );
|
||||||
|
|
||||||
if ( $old_data )
|
if ( $old_data )
|
||||||
return update_post_meta( $post_id, '_wp_attachment_metadata', $data, $old_data );
|
return update_post_meta( $post->ID, '_wp_attachment_metadata', $data, $old_data );
|
||||||
else
|
else
|
||||||
return add_post_meta( $post_id, '_wp_attachment_metadata', $data );
|
return add_post_meta( $post->ID, '_wp_attachment_metadata', $data );
|
||||||
}
|
}
|
||||||
|
|
||||||
function wp_get_attachment_url( $post_id = 0 ) {
|
function wp_get_attachment_url( $post_id = 0 ) {
|
||||||
@ -1429,37 +1431,41 @@ function wp_get_attachment_url( $post_id = 0 ) {
|
|||||||
if ( !$post =& get_post( $post_id ) )
|
if ( !$post =& get_post( $post_id ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$url = get_the_guid( $post_id );
|
$url = get_the_guid( $post->ID );
|
||||||
|
|
||||||
if ( 'attachment' != $post->post_type || !$url )
|
if ( 'attachment' != $post->post_type || !$url )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return apply_filters( 'wp_get_attachment_url', $url, $post_id );
|
return apply_filters( 'wp_get_attachment_url', $url, $post->ID );
|
||||||
}
|
}
|
||||||
|
|
||||||
function wp_get_attachment_thumb_file( $post_id ) {
|
function wp_get_attachment_thumb_file( $post_id = 0 ) {
|
||||||
$post_id = (int) $post_id;
|
$post_id = (int) $post_id;
|
||||||
if ( !$imagedata = wp_get_attachment_metadata( $post_id ) )
|
if ( !$post =& get_post( $post_id ) )
|
||||||
|
return false;
|
||||||
|
if ( !$imagedata = wp_get_attachment_metadata( $post->ID ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$file = get_attached_file( $post_id );
|
$file = get_attached_file( $post->ID );
|
||||||
|
|
||||||
if ( !empty($imagedata['thumb']) && ($thumbfile = str_replace(basename($file), $imagedata['thumb'], $file)) && file_exists($thumbfile) )
|
if ( !empty($imagedata['thumb']) && ($thumbfile = str_replace(basename($file), $imagedata['thumb'], $file)) && file_exists($thumbfile) )
|
||||||
return apply_filters( 'wp_get_attachment_thumb_file', $thumbfile, $post_id );
|
return apply_filters( 'wp_get_attachment_thumb_file', $thumbfile, $post->ID );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function wp_get_attachment_thumb_url( $post_id = 0 ) {
|
function wp_get_attachment_thumb_url( $post_id = 0 ) {
|
||||||
$post_id = (int) $post_id;
|
$post_id = (int) $post_id;
|
||||||
if ( !$url = wp_get_attachment_url( $post_id ) )
|
if ( !$post =& get_post( $post_id ) )
|
||||||
|
return false;
|
||||||
|
if ( !$url = wp_get_attachment_url( $post->ID ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( !$thumb = wp_get_attachment_thumb_file( $post_id ) )
|
if ( !$thumb = wp_get_attachment_thumb_file( $post->ID ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$url = str_replace(basename($url), basename($thumb), $url);
|
$url = str_replace(basename($url), basename($thumb), $url);
|
||||||
|
|
||||||
return apply_filters( 'wp_get_attachment_thumb_url', $url, $post_id );
|
return apply_filters( 'wp_get_attachment_thumb_url', $url, $post->ID );
|
||||||
}
|
}
|
||||||
|
|
||||||
function wp_attachment_is_image( $post_id = 0 ) {
|
function wp_attachment_is_image( $post_id = 0 ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user