diff --git src/wp-includes/media.php src/wp-includes/media.php
index a7db321..a090471 100644
|
|
function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = fa |
793 | 793 | } |
794 | 794 | |
795 | 795 | /** |
| 796 | * Get the URL of an image attachment. |
| 797 | * |
| 798 | * @since 4.4.0 |
| 799 | * |
| 800 | * @param int $attachment_id Image attachment ID. |
| 801 | * @param string|array $size Optional. Registered image size to retrieve the source for or a flat |
| 802 | * array of height and width dimensions. Default 'thumbnail'. |
| 803 | * @param bool $icon Optional. Whether the image should be treated as an icon. Default false. |
| 804 | * @return string|false Attachment URL or false if no image is available. |
| 805 | */ |
| 806 | function wp_get_attachment_image_url( $attachment_id, $size = 'thumbnail', $icon = false ) { |
| 807 | $image = wp_get_attachment_image_src( $attachment_id, $size, $icon ); |
| 808 | return isset( $image['0'] ) ? $image['0'] : false; |
| 809 | } |
| 810 | |
| 811 | /** |
796 | 812 | * Adds a 'wp-post-image' class to post thumbnails. Internal use only. |
797 | 813 | * |
798 | 814 | * Uses the 'begin_fetch_post_thumbnail_html' and 'end_fetch_post_thumbnail_html' action hooks to |
diff --git tests/phpunit/tests/media.php tests/phpunit/tests/media.php
index 34f1281..cdfb6cb 100644
|
|
EOF; |
718 | 718 | |
719 | 719 | remove_filter( 'embed_maybe_make_link', array( $this, 'filter_wp_embed_shortcode_custom' ), 10 ); |
720 | 720 | } |
| 721 | |
| 722 | function test_wp_get_attachment_image_url() { |
| 723 | $this->assertFalse( wp_get_attachment_image_url( 0 ) ); |
| 724 | |
| 725 | $post_id = $this->factory->post->create(); |
| 726 | $attachment_id = $this->factory->attachment->create_object( $this->img_name, $post_id, array( |
| 727 | 'post_mime_type' => 'image/jpeg', |
| 728 | 'post_type' => 'attachment', |
| 729 | ) ); |
| 730 | |
| 731 | $image = wp_get_attachment_image_src( $attachment_id, 'thumbnail', false ); |
| 732 | |
| 733 | $this->assertEquals( $image[0], wp_get_attachment_image_url( $attachment_id ) ); |
| 734 | } |
721 | 735 | } |