Ticket #17262: 17262.3.diff
File 17262.3.diff, 2.1 KB (added by , 7 years ago) |
---|
-
src/wp-includes/post.php
5073 5073 if ( !is_array( $imagedata = wp_get_attachment_metadata( $post->ID ) ) ) 5074 5074 return false; 5075 5075 5076 $thumbfile = false; 5076 5077 $file = get_attached_file( $post->ID ); 5077 5078 5078 if ( !empty($imagedata['thumb']) && ($thumbfile = str_replace(basename($file), $imagedata['thumb'], $file)) && file_exists($thumbfile) ) { 5079 if ( isset( $imagedata['sizes']['thumbnail']['file']) ) { 5080 $thumbfile = $imagedata['sizes']['thumbnail']['file']; 5081 } elseif ( isset( $imagedata['thumb'] ) ) { 5082 $thumbfile = $imagedata['thumb']; 5083 } 5084 5085 if ($thumbfile && file_exists(str_replace(basename($file), $thumbfile, $file)) ) { 5079 5086 /** 5080 5087 * Filter the attachment thumbnail file path. 5081 5088 * … … 5084 5091 * @param string $thumbfile File path to the attachment thumbnail. 5085 5092 * @param int $post_id Attachment ID. 5086 5093 */ 5087 returnapply_filters( 'wp_get_attachment_thumb_file', $thumbfile, $post->ID );5094 $thumbfile = apply_filters( 'wp_get_attachment_thumb_file', $thumbfile, $post->ID ); 5088 5095 } 5089 return false; 5096 5097 return $thumbfile; 5090 5098 } 5091 5099 5092 5100 /** -
tests/phpunit/tests/post/attachments.php
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 if ( !function_exists( 'imagejpeg' ) ) 529 $this->markTestSkipped( 'jpeg support unavailable' ); 530 531 $filename = ( DIR_TESTDATA.'/images/a2-small.jpg' ); 532 $contents = file_get_contents($filename); 533 534 $upload = wp_upload_bits(basename($filename), null, $contents); 535 $this->assertTrue( empty($upload['error']) ); 536 537 $id = $this->_make_attachment($upload); 538 539 $this->assertFalse(wp_get_attachment_thumb_file()); 540 $this->assertEquals('a2-small-150x150.jpg', wp_get_attachment_thumb_file($id)); 541 } 523 542 }