mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-03-31 02:34:38 +00:00
Media: Add a new function, wp_get_attachment_image_url(), which is a shortcut for wp_get_attachment_image_src() - same function signature, but returns just the URL based on $size.
Adds unit test. Props dipesh.kakadiya, swissspidy, sebastian.pisula. Fixes #33878. git-svn-id: https://develop.svn.wordpress.org/trunk@34372 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -718,4 +718,21 @@ EOF;
|
||||
|
||||
remove_filter( 'embed_maybe_make_link', array( $this, 'filter_wp_embed_shortcode_custom' ), 10 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 33878
|
||||
*/
|
||||
function test_wp_get_attachment_image_url() {
|
||||
$this->assertFalse( wp_get_attachment_image_url( 0 ) );
|
||||
|
||||
$post_id = $this->factory->post->create();
|
||||
$attachment_id = $this->factory->attachment->create_object( $this->img_name, $post_id, array(
|
||||
'post_mime_type' => 'image/jpeg',
|
||||
'post_type' => 'attachment',
|
||||
) );
|
||||
|
||||
$image = wp_get_attachment_image_src( $attachment_id, 'thumbnail', false );
|
||||
|
||||
$this->assertEquals( $image[0], wp_get_attachment_image_url( $attachment_id ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user