Image sizes not integers
-
When using wp_get_attachment_image() to include an image, the width and height were outputting as float values rather than integers.
I’ve got around this by adding the following filter to my functions:
function fix_direct_image_output($attr) { if(isset($attr['height'])) { $attr['height'] = intval($attr['height']); } if(isset($attr['width'])) { $attr['width'] = intval($attr['width']); } return $attr; } add_filter( 'wp_get_attachment_image_attributes', 'fix_direct_image_output', 11, 1 );
I’m not sure if fractional sizes were intentional or not but the W3C validator was reporting it as an error.
Version 1.9.3
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Image sizes not integers’ is closed to new replies.