Quantcast
Viewing all articles
Browse latest Browse all 94

gerald@wpcustoms on "IE7\8 compatibility - "px" attribute on images height\width"

Hello,

there is a minor bug in the image_hwstring function which took me quite some time to nail down.
I tested a theme in IE7 and IE8 browsers where images are floated with css + some responsive css rules.

those old IE browsers having massive problems when the image height+width attribute is missing "px".
WordPress renders:
height="100" width="200"
source here:
http://core.trac.wordpress.org/browser/trunk/wp-includes/media.php#L98

IE requires:
height="100px" width="200px"
google, chrome, safari can handle it easily if PX is missing but as you know IE is always a pain...

To make a long story short:
We came up with this solution and jumped into the get_image_tag function
http://core.trac.wordpress.org/browser/trunk/wp-includes/media.php#L223

function custom_dimensions($html, $id, $alt, $title, $align, $size){
    $html = preg_replace('%(width|height)(="[0-9]{1,4})(")%', '$1$2px$3', $html);
    return $html;
}
add_filter('get_image_tag', 'custom_dimensions',1, 6);

so my suggestion: please adjust the image_hwstring function and add the px to save a lot of headaches.

looking forward to hearing your opinions on this.
Thank you
Gerald


Viewing all articles
Browse latest Browse all 94

Trending Articles