Make WordPress Core

Opened 9 years ago

Last modified 6 years ago

#33768 new enhancement

Include image_meta in wp_prepare_attachment_for_js response for images

Reported by: stevehoneynz's profile SteveHoneyNZ Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.4
Component: Media Keywords: needs-unit-tests has-patch close
Focuses: Cc:

Description

Currently seems odd that the image_meta array isn't returned in the response from wp_prepare_attachment_for_js for an image.

The function already calls get_attachment_metadata so the image_meta array is readily available.
The meta key is already declared in the response array.
All other mime types populate the meta value in the response array in a similar fashion as my proposal.

I can't see any downside or overhead, and the function becomes much more powerful, particulaly for gallery implenmenations, as a result.

The addition is just three lines (in wp-includes/media.php #L2835 of current version).

Attachments (2)

include-image-metadata-wp-prepare-imagefor-js.php (7.5 KB) - added by SteveHoneyNZ 9 years ago.
33768.patch (643 bytes) - added by SteveHoneyNZ 9 years ago.

Download all attachments as: .zip

Change History (7)

#1 @SteveHoneyNZ
9 years ago

Should note the addition is at line 145 of the attached (uploaded only the wp_prepare_attachment_for_js function rather than entire media.php file).

Last edited 9 years ago by SteveHoneyNZ (previous) (diff)

#2 @swissspidy
9 years ago

  • Keywords needs-patch needs-unit-tests added

As I also mentioned on #33772, a real patch showing your changes would be nice.

Also, a unit test exists for the wp_prepare_attachment_for_js function which would need to be extended to reflect this change. You can read this section about automated testing to see what that means. Don't worry if it doesn't work or something, I'm sure someone else could help out too.

@SteveHoneyNZ
9 years ago

#3 @SteveHoneyNZ
9 years ago

Ok, added :) First Ticket, first patch, first time using SVN so apologies if anything's incorrect.

Not overly familiar with unit tests either but . I'm sure I'll get there too with a bit of investigating. Thanks for the pointers

#4 @SteveHoneyNZ
9 years ago

  • Keywords has-patch added; needs-patch removed

#5 @wonderboymusic
9 years ago

  • Keywords close added

The other types need the metadata to render in the admin/media modal properly. Images do not. $meta is available as a param to the 'wp_prepare_attachment_for_js' filter. I would suggest adding it to the response there.

Note: See TracTickets for help on using tickets.