• Resolved Richard

    (@richardj87)


    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)
  • Plugin Contributor Daryll Doyle

    (@enshrined)

    Thanks, @richardj87,

    I’ll look at getting a fix for this pushed out. I also wasn’t aware that float values for width and height weren’t valid. Nice catch!

    Cheers,
    Daryll

Viewing 1 replies (of 1 total)
  • The topic ‘Image sizes not integers’ is closed to new replies.