Make WordPress Core

Opened 16 years ago

Closed 16 years ago

#15841 closed defect (bug) (fixed)

Press This: Added images when using Press This are sourced incorrectly

Reported by: markel Owned by:
Priority: normal Milestone: 3.1
Component: Press This Version: 3.1
Severity: major Keywords: has-patch dev-reviewed
Cc: Focuses:

Description

Tested and verified in r16936.

Pulling an image from a source used when invoking Press This should return the image path itself in the post content and the image should be linked to its associated attachment page, but instead is sourcing the attachment page and is linking to the original article, like the following example.

The source document in this code snippet below is http://gameinternals.com/post/2072558330/understanding-pac-man-ghost-behavior

<div class="entry-content">
    <p>&nbsp;</p>
    <p style="text-align: center;"><a href="http://gameinternals.com/post/2072558330/understanding-pac-man-ghost-behavior"><img src='http://26mag.com/?attachment_id=3754' alt='' /></a></p>
    <p><a href="http://gameinternals.com/post/2072558330/understanding-pac-man-ghost-behavior">GameInternals &#8211; Understanding Pac-Man Ghost Behavior</a>.</p>
</div>

To reproduce:

  1. Open an article on another site.
  2. Invoke your Press This bookmarklet.
  3. Add an image from the source article by using the media tools in the Press This window.
  4. Draft the post.
  5. Preview the post and check source. The image will appear as a 404 (since the attachment page doesn't return an image file).

Attachments (2)

15841.diff (480 bytes ) - added by duck_ 16 years ago.
15841.2.diff (1.9 KB ) - added by duck_ 16 years ago.

Download all attachments as: .zip

Change History (7)

#1 @markel
16 years ago

  • Summary Press This: Added images when using Press This are sourced and linked incorrectlyPress This: Added images when using Press This are sourced incorrectly

I checked the old behavior again and the images are supposed to link back to the original article, but the sourcing is still bad. Modifying the ticket summary to be more accurate and please strike my comments on the linking from the above.

This is what happens when I make assumptions.

#2 @duck_
16 years ago

  • Keywords has-patch added
  • Milestone Awaiting Review3.1

The change to media_sideload_image as part of the changes in media_handle_sideload in [16383] for #15432 seems to incorrectly use get_attachment_link. Instead wp_get_attachment_url is what is wanted for the img tag's src attribute.

Noticing some extra non-breaking spaces when inserting the image which appears to be breaking the link on the default text, but for another ticket.

@duck_
16 years ago

@duck_
16 years ago

#3 @duck_
16 years ago

15841.2.diff is a better patch.

  • should check for WP_Error before using $id
  • escape $desc
  • don't use error suppression

#4 @westi
16 years ago

  • Keywords dev-reviewed added

Tested patch and it looks good and works for me.

#5 @westi
16 years ago

  • Resolutionfixed
  • Status newclosed

(In [17120]) Ensure that images added using Press This get the correct source url set. Fixes #15841 props duck_.

Note: See TracTickets for help on using tickets.