Make WordPress Core

Ticket #32695: 32695.diff

File 32695.diff, 1.0 KB (added by kraftbj, 10 years ago)

Adds new id return.

  • src/wp-admin/includes/media.php

     
    835835 * @param string $file    The URL of the image to download.
    836836 * @param int    $post_id The post ID the media is to be associated with.
    837837 * @param string $desc    Optional. Description of the image.
    838  * @param string $return  Optional. Accepts 'html' (image tag html) or 'src' (URL). Default 'html'.
     838 * @param string $return  Optional. Accepts 'html' (image tag html), 'src' (URL), or 'id' (attachment ID). Default 'html'.
    839839 * @return string|WP_Error Populated HTML img tag on success, WP_Error object otherwise.
    840840 */
    841841function media_sideload_image( $file, $post_id, $desc = null, $return = 'html' ) {
     
    872872                        return $src;
    873873                }
    874874
     875                if ( $return === 'id' ) {
     876                        return $id;
     877                }
     878
    875879                $alt = isset( $desc ) ? esc_attr( $desc ) : '';
    876880                $html = "<img src='$src' alt='$alt' />";
    877881                return $html;