Make WordPress Core

Opened 10 years ago

Last modified 7 years ago

#39521 new defect (bug)

media_handle_sideload does not initialize the caption/excerpt value

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

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 10 years ago.
initial patch

Download all attachments as: .zip

Change History (6)

@Presskopp
10 years ago

initial patch

#1 @Presskopp
10 years ago

  • Version trunk → 2.6

#2 @desrosj
9 years ago

  • Keywords has-patch needs-refresh added

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


8 years ago

#4 @aaroncampbell
8 years 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
7 years 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.