#32093 closed defect (bug) (fixed)
Inconsistent class names between get_image_tag() and wp_get_image_attachment()
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Media | Keywords: | has-patch |
Focuses: | Cc: |
Description
get_image_tag()
generates size class attribute as size-[size]
, while wp_get_attachment_image()
generates size class attribute as attachment-[size]
.
Since the former is called when inserting any image via get_image_send_to_editor()
, while the latter is basically called when in plugins, post thumbnails, and the gallery shortcode, it would be best to settle on size-[size]
as the likelihood of it breaking downstream code is smaller.
However at this point there are a number of plugins and themes that try to modify post thumbnails and they will break if they hook off of it. (e.g a css class modifying .attachment-thumbnails
, or the mobile minileven theme in jetpack, also the site logo tool copies the improperly generated class.) So you may not want to fix this bug, or you may want to make the function generate both classes.
To understand why this is a bug, for s--ts-and-giggles, try registering sizes that have the name "meta" in many themes (the wp-admin uses that class on divs in the upload and a number of themes like twenty thirteen have modeled themselves after it), or install the Isabelle theme and register and use sizes "caption" or "desc" (they'll get centered no matter what).
Not sure it can be fixed at this point, but probably deserves a trac item so it can be searched for as a RESOLVED WONTFIX
I would prefer adding
size-{size}
, as the OP suggests, towp_get_attachment_image()
rather than addingattachment-{size}
toget_post_image()
unless there's a reason not to. Seems likely that there would potentially be less collisions with other things using.attachment-{foo}
class selectors in their CSS.