WordPress.org

Make WordPress Core

Changeset 46245


Ignore:
Timestamp:
09/23/2019 04:02:38 PM (3 weeks ago)
Author:
antpb
Message:

Media: Sets post_id optional in media_sideload_image() and media_handle_sideload().
Props SergeyBiryukov, donmhico, mikeschroder, sebastian.pisula.
Fixes #43579.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/media.php

    r46174 r46245  
    433433 *
    434434 * @since 2.6.0
     435 * @since 5.3.0 Made `$post_id` parameter optional.
    435436 *
    436437 * @param array  $file_array Array similar to a `$_FILES` upload array.
    437  * @param int    $post_id    The post ID the media is associated with.
     438 * @param int    $post_id    Optional. The post ID the media is associated with.
    438439 * @param string $desc       Optional. Description of the side-loaded file. Default null.
    439440 * @param array  $post_data  Optional. Post data to override. Default empty array.
    440441 * @return int|WP_Error The ID of the attachment or a WP_Error on failure.
    441442 */
    442 function media_handle_sideload( $file_array, $post_id, $desc = null, $post_data = array() ) {
     443function media_handle_sideload( $file_array, $post_id = 0, $desc = null, $post_data = array() ) {
    443444    $overrides = array( 'test_form' => false );
    444445
     
    970971 * @since 4.2.0 Introduced the `$return` parameter.
    971972 * @since 4.8.0 Introduced the 'id' option within the `$return` parameter.
     973 * @since 5.3.0 Made the `$post_id` parameter optional
    972974 *
    973975 * @param string $file    The URL of the image to download.
    974  * @param int    $post_id The post ID the media is to be associated with.
     976 * @param int    $post_id Optional. The post ID the media is to be associated with.
    975977 * @param string $desc    Optional. Description of the image.
    976978 * @param string $return  Optional. Accepts 'html' (image tag html) or 'src' (URL), or 'id' (attachment ID). Default 'html'.
    977979 * @return string|WP_Error Populated HTML img tag on success, WP_Error object otherwise.
    978980 */
    979 function media_sideload_image( $file, $post_id, $desc = null, $return = 'html' ) {
     981function media_sideload_image( $file, $post_id = 0, $desc = null, $return = 'html' ) {
    980982    if ( ! empty( $file ) ) {
    981983
Note: See TracChangeset for help on using the changeset viewer.