Opened 9 years ago
Closed 9 years ago
#34612 closed defect (bug) (fixed)
Responsive Images: Make new function/filter signatures more consistent
Reported by: | joemcgill | Owned by: | azaozz |
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Media | Keywords: | has-patch |
Focuses: | Cc: |
Description
As a part of the responsive images features being added in 4.4, we should promote internal consistency in the new functions and filters we're adding. To that end, several of us working on this feature have discussed splitting wp_get_attachment_image_sizes()
into two functions: an internally used function that calculates the sizes attribute, and an external use function that can be used easily in themes. This mimics the pattern we already established with wp_calculate_image_srcset()
and wp_get_attachment_image_srceset()
.
Attachments (6)
Change History (19)
This ticket was mentioned in Slack in #feature-respimg by joemcgill. View the logs.
9 years ago
#4
follow-up:
↓ 6
@
9 years ago
Looks like I missed updating the params for wp_calculate_image_srcset
filter in 34612.diff. I've uploaded 34612.filter.diff, which corrects the param order and adds $image_src
to the filter. Inline docs are updated as well.
#6
in reply to:
↑ 4
@
9 years ago
- Keywords commit removed
Replying to joemcgill:
Looks like I missed updating the params for
wp_calculate_image_srcset
filter in 34612.diff. I've uploaded 34612.filter.diff, which corrects the param order and adds$image_src
to the filter. Inline docs are updated as well.
We're going to have to move the code example into the hook doc description. As-is, it would be read as a sentence with the extra spaces removed. So let's move it to the description, four-space indented and figure out a good way to refer back to it from the parameter description.
#7
@
9 years ago
After discussion with @DrewAPicture, in 34612.filter.2.diff I've changed the inline docs to use proper @type
docs for the array of sources being passed in the wp_calculate_image_srcset
filter, per the inline docs handbook.
#10
@
9 years ago
@DrewAPicture Super minor, but there's a blank line in the inline docs L1092. Removed in .2.diff.
#12
@
9 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
I noticed that we had marked several params in wp_calcuate_image_sizes()
as optional, but had not defined default values. 34612.4.diff corrects this issue and includes a few other fixes to the docblocs for this function and filter.
34612.diff moves the logic of
wp_get_attachment_image_sizes()
towp_calculate_image_sizes()
and renames the filterwp_calculate_image_sizes()
. The parameter order now matches the order or params inwp_calculate_image_srcset()
.The previous function name:
wp_get_attachment_image_sizes()
now accepts an attachment id and optional size parameter, which matches the signature ofwp_get_attachment_image_srcset()
and is consistent with the otherwp_get_attachment_image_
template functions.Tests and docs have been updated.