Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#29869 closed defect (bug) (fixed)

Pass $size to wp_get_attachment_image_attributes filter

Reported by: mattheu's profile mattheu Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 4.1 Priority: normal
Severity: normal Version:
Component: Media Keywords: has-patch
Focuses: Cc:

Description

It would be useful to have access to the originally requested image size in the wp_get_attachment_image_attributes filter.

Use case: the srcset attribute has recently been introduced - and is useful for adding 2x (3x etc) high res images for devices with high res screens. If plugins were able to access the size in this filter, it could be used to add this.

Somewhat related - but not the same: #14110

Attachments (2)

29869.diff (900 bytes) - added by mattheu 10 years ago.
29869.2.diff (1.8 KB) - added by mattheu 10 years ago.
Pass original size not value modified for use in class

Download all attachments as: .zip

Change History (8)

@mattheu
10 years ago

#1 follow-up: @SergeyBiryukov
10 years ago

  • Component changed from General to Media
  • Milestone changed from Awaiting Review to 4.1

$size cannot be an array at that point, see line 702.

Should we pass that 1024x768-like string to the filter, or the original requested array?

#2 in reply to: ↑ 1 @DrewAPicture
10 years ago

Replying to SergeyBiryukov:

$size cannot be an array at that point, see line 702.

Should we pass that 1024x768-like string to the filter, or the original requested array?

I vote we store the value of $size before it's (maybe) modified and pass that to the filter.

#3 @DrewAPicture
10 years ago

  • Keywords has-patch added

@mattheu
10 years ago

Pass original size not value modified for use in class

#4 @mattheu
10 years ago

Updated patch - instead of storing the original value of size I've used a $size_class variable as I think its a little neater.

#5 @SergeyBiryukov
10 years ago

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

In 29836:

Pass the requested size to 'wp_get_attachment_image_attributes' filter.

props mattheu.
fixes #29869.

#6 @SergeyBiryukov
10 years ago

In 29837:

Update @param docs for wp_get_attachment_image().

see #29869.

Note: See TracTickets for help on using tickets.