[wp-trac] [WordPress Trac] #20358: Filter image_hwstring()

WordPress Trac noreply at wordpress.org
Fri Nov 24 14:54:19 UTC 2017


#20358: Filter image_hwstring()
--------------------------+-----------------------
 Reporter:  wpsmith       |       Owner:
     Type:  defect (bug)  |      Status:  reopened
 Priority:  normal        |   Milestone:
Component:  Media         |     Version:
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+-----------------------
Changes (by Cibulka):

 * status:  closed => reopened
 * resolution:  duplicate =>


Comment:

 Thanks for the quick reply!

 CSS **can** override this, but don't you agree it's a little bit silly to
 fix incorrect output with CSS? Wouldn't be easier to simply make this
 function filterable?

 I'm not the lonely head scratcher here:

 - https://wordpress.stackexchange.com/questions/29881/stop-wordpress-from-
 hardcoding-img-width-and-height-attributes
 - https://wordpress.stackexchange.com/questions/22302/how-do-you-remove-
 hard-coded-thumbnail-image-dimensions
 - https://wordpress.stackexchange.com/questions/5568/filter-to-remove-
 image-dimension-attributes
 - https://gist.github.com/stuntbox/4557917 (59 stars)
 - https://wpbeaches.com/responsively-removing-width-and-height-attributes-
 in-images-on-wordpress/
 - http://wpcrux.com/blog/remove-image-attachment-dimensions/

 ... and many, many more.

 I've ended up with very complex filtering of `image_downsize` function:
 https://gist.github.com/cibulka/8e2bf16b0f55779af590472ae1bf9239

 The gist of the sollution is to remove image dimmensions from
 `image_downsize` function, as it is the only way (!!!) how to influence
 `image_hwstring`.

 One of many side effects of this sollutions is that
 `wp_get_attachment_src` obviously stops returning image dimmensions - so
 for this functionality I needed to programme my own function.

 Wouldn't is just be easier to make a filter? :)

--
Ticket URL: <https://core.trac.wordpress.org/ticket/20358#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list