Changeset 17120
- Timestamp:
- 12/23/2010 03:41:05 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/media.php
r17071 r17120 271 271 } 272 272 273 $title = @$desc;273 $title = isset($desc) ? $desc : ''; 274 274 275 275 // Construct the attachment array … … 548 548 549 549 /** 550 * {@internal Missing Short Description}}550 * Download an image from the specified URL and attach it to a post. 551 551 * 552 552 * @since 2.6.0 553 553 * 554 * @param unknown_type $file555 * @param unknown_type $post_id556 * @param unknown_type $desc557 * @return unknown554 * @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 558 558 */ 559 559 function media_sideload_image($file, $post_id, $desc = null) { 560 if ( !empty($file) ) {560 if ( ! empty($file) ) { 561 561 // Download file to temp location 562 $tmp = download_url( $file);562 $tmp = download_url( $file ); 563 563 564 564 // Set variables for storage … … 575 575 576 576 // 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 ); 580 578 // If error storing permanently, unlink 581 579 if ( is_wp_error($id) ) { … … 583 581 return $id; 584 582 } 583 584 $src = wp_get_attachment_url( $id ); 585 585 } 586 586 587 587 // 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) : ''; 590 590 $html = "<img src='$src' alt='$alt' />"; 591 591 return $html;
Note: See TracChangeset
for help on using the changeset viewer.