Changeset 32352
- Timestamp:
- 05/05/2015 02:19:47 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
r32350 r32352 823 823 824 824 /** 825 * Download an image from the specified URL and attachit to a post.825 * Downloads an image from the specified URL and attaches it to a post. 826 826 * 827 827 * @since 2.6.0 828 828 * @since 4.2.0 Introduced the `$return` parameter. 829 829 * 830 * @param string $file The URL of the image to download831 * @param int $post_id The post ID the media is to be associated with832 * @param string $desc Optional. Description of the image833 * @param string $return Optional. Accepts 'html' (image tag html) or 'src' (URL). Default 'html'.834 * @return string|WP_Error Populated HTML img tag on success 830 * @param string $file The URL of the image to download. 831 * @param int $post_id The post ID the media is to be associated with. 832 * @param string $desc Optional. Description of the image. 833 * @param string $return Optional. Accepts 'html' (image tag html) or 'src' (URL). Default 'html'. 834 * @return string|WP_Error Populated HTML img tag on success, WP_Error object otherwise. 835 835 */ 836 836 function media_sideload_image( $file, $post_id, $desc = null, $return = 'html' ) { 837 837 if ( ! empty( $file ) ) { 838 838 839 // Set variables for storage, fix file filename for query strings. 839 840 preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches ); … … 861 862 } 862 863 863 // Finally check to make sure the file has been saved, then return the HTML.864 // Finally, check to make sure the file has been saved, then return the HTML. 864 865 if ( ! empty( $src ) ) { 865 866 if ( $return === 'src' ) {
Note: See TracChangeset
for help on using the changeset viewer.