Make WordPress Core

Changeset 17120


Ignore:
Timestamp:
12/23/2010 03:41:05 PM (14 years ago)
Author:
westi
Message:

Ensure that images added using Press This get the correct source url set. Fixes #15841 props duck_.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/media.php

    r17071 r17120  
    271271    }
    272272
    273     $title = @$desc;
     273    $title = isset($desc) ? $desc : '';
    274274
    275275    // Construct the attachment array
     
    548548
    549549/**
    550  * {@internal Missing Short Description}}
     550 * Download an image from the specified URL and attach it to a post.
    551551 *
    552552 * @since 2.6.0
    553553 *
    554  * @param unknown_type $file
    555  * @param unknown_type $post_id
    556  * @param unknown_type $desc
    557  * @return unknown
     554 * @param string $file The URL of the image to download
     555 * @param int $post_id The post ID the media is to be associated with
     556 * @param string $desc Optional. Description of the image
     557 * @return string|WP_Error Populated HTML img tag on success
    558558 */
    559559function media_sideload_image($file, $post_id, $desc = null) {
    560     if (!empty($file) ) {
     560    if ( ! empty($file) ) {
    561561        // Download file to temp location
    562         $tmp = download_url($file);
     562        $tmp = download_url( $file );
    563563
    564564        // Set variables for storage
     
    575575
    576576        // do the validation and storage stuff
    577         $id = media_handle_sideload( $file_array, $post_id, @$desc );
    578         $src = get_attachment_link( $id );
    579 
     577        $id = media_handle_sideload( $file_array, $post_id, $desc );
    580578        // If error storing permanently, unlink
    581579        if ( is_wp_error($id) ) {
     
    583581            return $id;
    584582        }
     583
     584        $src = wp_get_attachment_url( $id );
    585585    }
    586586
    587587    // Finally check to make sure the file has been saved, then return the html
    588     if ( !empty($src) ) {
    589         $alt = @$desc;
     588    if ( ! empty($src) ) {
     589        $alt = isset($desc) ? esc_attr($desc) : '';
    590590        $html = "<img src='$src' alt='$alt' />";
    591591        return $html;
Note: See TracChangeset for help on using the changeset viewer.