Changeset 53192
- Timestamp:
- 04/17/2022 10:49:10 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/media.php
r52837 r53192 975 975 * 976 976 * @since 2.6.0 977 * @since 4.2.0 Introduced the `$return ` parameter.978 * @since 4.8.0 Introduced the 'id' option for the `$return ` parameter.977 * @since 4.2.0 Introduced the `$return_type` parameter. 978 * @since 4.8.0 Introduced the 'id' option for the `$return_type` parameter. 979 979 * @since 5.3.0 The `$post_id` parameter was made optional. 980 980 * @since 5.4.0 The original URL of the attachment is stored in the `_source_url` 981 981 * post meta value. 982 982 * 983 * @param string $file The URL of the image to download.984 * @param int $post_id Optional. The post ID the media is to be associated with.985 * @param string $desc Optional. Description of the image.986 * @param string $return 987 * or 'id' (attachment ID). Default 'html'.983 * @param string $file The URL of the image to download. 984 * @param int $post_id Optional. The post ID the media is to be associated with. 985 * @param string $desc Optional. Description of the image. 986 * @param string $return_type Optional. Accepts 'html' (image tag html) or 'src' (URL), 987 * or 'id' (attachment ID). Default 'html'. 988 988 * @return string|int|WP_Error Populated HTML img tag, attachment ID, or attachment source 989 989 * on success, WP_Error object otherwise. 990 990 */ 991 function media_sideload_image( $file, $post_id = 0, $desc = null, $return = 'html' ) {991 function media_sideload_image( $file, $post_id = 0, $desc = null, $return_type = 'html' ) { 992 992 if ( ! empty( $file ) ) { 993 993 … … 1044 1044 1045 1045 // If attachment ID was requested, return it. 1046 if ( 'id' === $return ) {1046 if ( 'id' === $return_type ) { 1047 1047 return $id; 1048 1048 } … … 1053 1053 // Finally, check to make sure the file has been saved, then return the HTML. 1054 1054 if ( ! empty( $src ) ) { 1055 if ( 'src' === $return ) {1055 if ( 'src' === $return_type ) { 1056 1056 return $src; 1057 1057 }
Note: See TracChangeset
for help on using the changeset viewer.