Ticket #19629: 19629.diff
File 19629.diff, 1.1 KB (added by , 13 years ago) |
---|
-
wp-admin/includes/media.php
586 586 * @param string $file The URL of the image to download 587 587 * @param int $post_id The post ID the media is to be associated with 588 588 * @param string $desc Optional. Description of the image 589 * @return string|WP_Error Populated HTML img tag on success 589 * @param bool $return_html Optional. Whether to return the HTML img tag or attachment ID 590 * @return string|int|WP_Error Populated HTML img tag or attachment ID on success, WP_Error on failure 590 591 */ 591 function media_sideload_image($file, $post_id, $desc = null ) {592 function media_sideload_image($file, $post_id, $desc = null, $return_html = true) { 592 593 if ( ! empty($file) ) { 593 594 // Download file to temp location 594 595 $tmp = download_url( $file ); … … 620 621 if ( ! empty($src) ) { 621 622 $alt = isset($desc) ? esc_attr($desc) : ''; 622 623 $html = "<img src='$src' alt='$alt' />"; 623 return $ html;624 return $return_html ? $html : $id; 624 625 } 625 626 } 626 627