diff --git a/src/wp-admin/includes/media.php b/src/wp-admin/includes/media.php
index c6b2dcd..de937cf 100644
a
|
b
|
function wp_media_upload_handler() { |
848 | 848 | * @param string $file The URL of the image to download. |
849 | 849 | * @param int $post_id The post ID the media is to be associated with. |
850 | 850 | * @param string $desc Optional. Description of the image. |
851 | | * @param string $return Optional. Accepts 'html' (image tag html) or 'src' (URL). Default 'html'. |
| 851 | * @param string $return Optional. Accepts 'html' (image tag html), 'id' (Media ID), or 'src' (URL). Default 'html'. |
852 | 852 | * @return string|WP_Error Populated HTML img tag on success, WP_Error object otherwise. |
853 | 853 | */ |
854 | 854 | function media_sideload_image( $file, $post_id, $desc = null, $return = 'html' ) { |
… |
… |
function media_sideload_image( $file, $post_id, $desc = null, $return = 'html' ) |
884 | 884 | } |
885 | 885 | |
886 | 886 | // Finally, check to make sure the file has been saved, then return the HTML. |
887 | | if ( ! empty( $src ) ) { |
888 | | if ( $return === 'src' ) { |
889 | | return $src; |
890 | | } |
891 | | |
892 | | $alt = isset( $desc ) ? esc_attr( $desc ) : ''; |
893 | | $html = "<img src='$src' alt='$alt' />"; |
894 | | return $html; |
895 | | } else { |
| 887 | if ( empty( $src ) ) { |
896 | 888 | return new WP_Error( 'image_sideload_failed' ); |
897 | 889 | } |
| 890 | |
| 891 | if ( $return === 'src' ) { |
| 892 | return $src; |
| 893 | } |
| 894 | |
| 895 | if ( $return === 'id' ) { |
| 896 | return $id; |
| 897 | } |
| 898 | |
| 899 | $alt = isset( $desc ) ? esc_attr( $desc ) : ''; |
| 900 | $html = "<img src='$src' alt='$alt' />"; |
| 901 | return $html; |
898 | 902 | } |
899 | 903 | |
900 | 904 | /** |