Changeset 31799 for trunk/src/wp-admin/includes/media.php
- Timestamp:
- 03/17/2015 12:46:01 AM (11 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-admin/includes/media.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/media.php
r31694 r31799 830 830 * @param int $post_id The post ID the media is to be associated with 831 831 * @param string $desc Optional. Description of the image 832 * @param string $return Optional. What to return: an image tag (default) or only the src. 832 833 * @return string|WP_Error Populated HTML img tag on success 833 834 */ 834 function media_sideload_image( $file, $post_id, $desc = null ) {835 function media_sideload_image( $file, $post_id, $desc = null, $return = 'html' ) { 835 836 if ( ! empty( $file ) ) { 836 837 // Set variables for storage, fix file filename for query strings. … … 861 862 // Finally check to make sure the file has been saved, then return the HTML. 862 863 if ( ! empty( $src ) ) { 864 if ( $return === 'src' ) { 865 return $src; 866 } 867 863 868 $alt = isset( $desc ) ? esc_attr( $desc ) : ''; 864 869 $html = "<img src='$src' alt='$alt' />"; 865 870 return $html; 871 } else { 872 return new WP_Error( 'image_sideload_failed' ); 866 873 } 867 874 }
Note: See TracChangeset
for help on using the changeset viewer.