WordPress.org

Make WordPress Core

Ticket #19629: 19629.diff

File 19629.diff, 1.1 KB (added by kawauso, 9 years ago)

Use $return_html instead

  • wp-admin/includes/media.php

     
    586586 * @param string $file The URL of the image to download
    587587 * @param int $post_id The post ID the media is to be associated with
    588588 * @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
    590591 */
    591 function media_sideload_image($file, $post_id, $desc = null) {
     592function media_sideload_image($file, $post_id, $desc = null, $return_html = true) {
    592593        if ( ! empty($file) ) {
    593594                // Download file to temp location
    594595                $tmp = download_url( $file );
     
    620621        if ( ! empty($src) ) {
    621622                $alt = isset($desc) ? esc_attr($desc) : '';
    622623                $html = "<img src='$src' alt='$alt' />";
    623                 return $html;
     624                return $return_html ? $html : $id;
    624625        }
    625626}
    626627