diff --git src/wp-includes/post.php src/wp-includes/post.php
index 72ffc8d..6ada1b2 100644
|
|
|
function wp_get_attachment_url( $post_id = 0 ) {
|
| 5060 | 5060 | } |
| 5061 | 5061 | |
| 5062 | 5062 | /** |
| 5063 | | * Retrieve thumbnail for an attachment. |
| | 5063 | * Retrieves the thumbnail for an attachment. |
| 5064 | 5064 | * |
| 5065 | 5065 | * @since 2.1.0 |
| 5066 | 5066 | * |
| … |
… |
function wp_get_attachment_thumb_file( $post_id = 0 ) {
|
| 5074 | 5074 | if ( !is_array( $imagedata = wp_get_attachment_metadata( $post->ID ) ) ) |
| 5075 | 5075 | return false; |
| 5076 | 5076 | |
| | 5077 | $thumbfile = false; |
| 5077 | 5078 | $file = get_attached_file( $post->ID ); |
| 5078 | 5079 | |
| 5079 | | if ( !empty($imagedata['thumb']) && ($thumbfile = str_replace(basename($file), $imagedata['thumb'], $file)) && file_exists($thumbfile) ) { |
| | 5080 | if ( isset( $imagedata['sizes']['thumbnail']['file'] ) ) { |
| | 5081 | $thumbfile = $imagedata['sizes']['thumbnail']['file']; |
| | 5082 | } elseif ( isset( $imagedata['thumb'] ) ) { |
| | 5083 | $thumbfile = $imagedata['thumb']; |
| | 5084 | } |
| | 5085 | |
| | 5086 | if ( $thumbfile && file_exists( str_replace( basename( $file ), $thumbfile, $file ) ) ) { |
| 5080 | 5087 | /** |
| 5081 | | * Filter the attachment thumbnail file path. |
| | 5088 | * Filters the attachment thumbnail file path. |
| 5082 | 5089 | * |
| 5083 | 5090 | * @since 2.1.0 |
| 5084 | 5091 | * |
| 5085 | 5092 | * @param string $thumbfile File path to the attachment thumbnail. |
| 5086 | 5093 | * @param int $post_id Attachment ID. |
| 5087 | 5094 | */ |
| 5088 | | return apply_filters( 'wp_get_attachment_thumb_file', $thumbfile, $post->ID ); |
| | 5095 | $thumbfile = apply_filters( 'wp_get_attachment_thumb_file', $thumbfile, $post->ID ); |
| 5089 | 5096 | } |
| 5090 | | return false; |
| | 5097 | |
| | 5098 | return $thumbfile; |
| 5091 | 5099 | } |
| 5092 | 5100 | |
| 5093 | 5101 | /** |
diff --git tests/phpunit/tests/post/attachments.php tests/phpunit/tests/post/attachments.php
index 3df4ce4..7d8030f 100644
|
|
|
class Tests_Post_Attachments extends WP_UnitTestCase {
|
| 520 | 520 | |
| 521 | 521 | $this->assertContains( 'images/media/video.png', $icon ); |
| 522 | 522 | } |
| | 523 | |
| | 524 | /** |
| | 525 | * @ticket 17262 |
| | 526 | */ |
| | 527 | public function test_wp_get_attachment_thumb_file() { |
| | 528 | $filename = ( DIR_TESTDATA . '/images/a2-small.jpg' ); |
| | 529 | $contents = file_get_contents( $filename ); |
| | 530 | |
| | 531 | $upload = wp_upload_bits( basename( $filename ), null, $contents ); |
| | 532 | $this->assertTrue( empty( $upload['error'] ) ); |
| | 533 | |
| | 534 | $id = $this->_make_attachment( $upload ); |
| | 535 | |
| | 536 | $this->assertFalse( wp_get_attachment_thumb_file() ); |
| | 537 | $this->assertEquals( 'a2-small-150x150.jpg', wp_get_attachment_thumb_file( $id ) ); |
| | 538 | } |
| 523 | 539 | } |