Changeset 47251
- Timestamp:
- 02/10/2020 11:45:50 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/media.php
r47219 r47251 968 968 * @since 4.8.0 Introduced the 'id' option within the `$return` parameter. 969 969 * @since 5.3.0 The `$post_id` parameter was made optional. 970 * @since 5.4.0 The original URL of the attachment is stored in the `_source_url` 971 * post meta value. 970 972 * 971 973 * @param string $file The URL of the image to download. 972 974 * @param int $post_id Optional. The post ID the media is to be associated with. 973 975 * @param string $desc Optional. Description of the image. 974 * @param string $return Optional. Accepts 'html' (image tag html) or 'src' (URL), or 'id' (attachment ID). Default 'html'. 976 * @param string $return Optional. Accepts 'html' (image tag html) or 'src' (URL), 977 * or 'id' (attachment ID). Default 'html'. 975 978 * @return string|WP_Error Populated HTML img tag on success, WP_Error object otherwise. 976 979 */ … … 1003 1006 @unlink( $file_array['tmp_name'] ); 1004 1007 return $id; 1005 // If attachment id was requested, return it early. 1006 } elseif ( 'id' === $return ) { 1008 } 1009 1010 // Store the original attachment source in meta. 1011 add_post_meta( $id, '_source_url', $file ); 1012 1013 // If attachment id was requested, return it. 1014 if ( 'id' === $return ) { 1007 1015 return $id; 1008 1016 }
Note: See TracChangeset
for help on using the changeset viewer.