WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 5 months ago

#39521 new defect (bug)

media_handle_sideload does not initialize the caption/excerpt value

Reported by: dglingren Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 2.6
Component: Media Keywords:
Focuses: Cc:
PR Number:

Description

In /wp-admin/includes/media.php changes have been made in the media_handle_upload() function to initialize the caption/excerpt value after an upload. Here's the code:

<?php
        // Construct the attachment array
        $attachment = array_merge( array(
                'post_mime_type' => $type,
                'guid' => $url,
                'post_parent' => $post_id,
                'post_title' => $title,
                'post_content' => $content,
                'post_excerpt' => $excerpt,
        ), $post_data );

Corresponding changes should be made in the media_handle_sideload() function, which still has:

<?php
        // Construct the attachment array.
        $attachment = array_merge( array(
                'post_mime_type' => $type,
                'guid' => $url,
                'post_parent' => $post_id,
                'post_title' => $title,
                'post_content' => $content,
        ), $post_data )

Attachments (1)

39521.diff (457 bytes) - added by Presskopp 3 years ago.
initial patch

Download all attachments as: .zip

Change History (6)

@Presskopp
3 years ago

initial patch

#1 @Presskopp
3 years ago

  • Version changed from trunk to 2.6

#2 @desrosj
22 months ago

  • Keywords has-patch needs-refresh added

This ticket was mentioned in Slack in #core-media by mike. View the logs.


10 months ago

#4 @aaroncampbell
10 months ago

  • Keywords has-patch needs-refresh removed

Looking into this it seems like the patch tries to use $excerpt which doesn't exist inside media_handle_sideload(). It also looks like the $content variable in sideload is the same as the $excerpt variable media_handle_upload(). To bring parity between the two is seems like that needs to go into post_excerpt and the functionality for filling in $content needs to be brought over from media_handle_upload().

Having said all that: I'm not sure of the historical context here or why these seem to be treating content/excerpt differently. Some more digging is needed, but I'm removing the has-patch tag since the patch here won't fix the issue.

#5 @WayneAllen
5 months ago

As of WordPress 5.2 media_handle_sideload does not set the caption correctly. It attempts to put the caption in post_content rather than post_excerpt.

Note: See TracTickets for help on using tickets.