WordPress.org

Make WordPress Core

#24188 closed defect (bug) (fixed)

Post Formats: get_the_post_format_image doesn't return the requested size

Reported by: kovshenin Owned by: markjaquith
Milestone: 3.6 Priority: normal
Severity: normal Version: 3.6
Component: Post Formats Keywords: has-patch
Focuses: Cc:

Description

The new get_the_post_format_image function accepts an $attached_size argument, but the value is ignored for the following cases:

  • Image meta has a caption shortcode and image HTML
  • Image meta is an image URL
  • Image meta is an image HTML string
  • Image meta is empty, but content contains image HTML

The only way this seems to work as expected is when the get_attached_images-way and when the meta is numeric.

Attachments (2)

24188.diff (3.5 KB) - added by kovshenin 12 months ago.
24188.2.diff (3.5 KB) - added by kovshenin 11 months ago.

Download all attachments as: .zip

Change History (5)

kovshenin12 months ago

comment:1 kovshenin12 months ago

  • Keywords has-patch added

Related to #23945 and #24002 but not duplicates. This has nothing to do with the way results are cached.

24188.diff introduces a new function to get an attachment ID out of HTML containing an image. This function is then used in get_the_post_format_image where applicable. Somewhat regex-heavy.

kovshenin11 months ago

comment:2 kovshenin11 months ago

Refreshed in 24188.2.diff:

  • Uses backreference to match the closing single or double quote in img_html_to_post_id and get_the_post_format_image (see also #24225)
  • Use $attr in img_html_to_post_id instead of $src which is undefined

comment:3 markjaquith11 months ago

  • Owner set to markjaquith
  • Resolution set to fixed
  • Status changed from new to closed

In 24240:

Return the requested image size in get_the_post_format_image()

props kovshenin. fixes #24188.

Note: See TracTickets for help on using tickets.