Opened 11 years ago
Closed 11 years ago
#24060 closed defect (bug) (fixed)
Post formats: `get_the_post_format_image()` splitting content doesn't work when "intermediate_image_sizes" result is empty
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.6 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Post Formats | Keywords: | has-patch |
Focuses: | Cc: |
Description
get_the_post_format_image()
splits out an image from post content, to avoid duplicating it when a theme choose to output split content.
Unfortunately, not all WP installs will have "default" or "expected" image sizes, like 'thumbnail', 'medium', 'large' etc.
For example, on WordPress.com this call results in an empty array:
$sizes = get_intermediate_image_sizes();
I think to improve the content parsing two improvements can be made:
- Move
get_attachment_link( $media->ID )
out of the foreach loop for$sizes
-- that URL will be the same for each size, it's just the permalink to the attachment page - Add the "original" image source path to the
$urls
array, which is the image path with no size information. The original uploaded file path can then be used to parse out images from the main content even if the expected size list is empty.
Attachments (3)
Change History (11)
#3
@
11 years ago
Per kovshenin's keen eye — patch updated to use "full" image size to get the original image source path.
#5
@
11 years ago
The extra get_attachment_link()
calls still present in a recent change: r23992 -- they are all still the same, and only one is needed. ;)
#6
@
11 years ago
Note that @wonderboymusic's attachment:ticket:23965:23965.diff patch fixes moving out the one reference link out of the loop.
As an explanatory note for # 1 above (move permalink out of foreach loop) this is an example debug for an Image post format:
You'll see that the permalink is the same for each size, so it's not necessary to have it in the loop.