Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 2.3.1 #122

Merged
merged 9 commits into from
May 27, 2015
22 changes: 22 additions & 0 deletions tests/test-suite.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,28 @@ function test_tevkori_get_srcset_array_false() { // make an image
$this->assertFalse( $sizes );
}

function test_tevkori_get_srcset_array_no_width() {
// Filter image_downsize() output.
add_filter( 'image_downsize', array( $this, '_test_tevkori_get_srcset_array_no_width_filter' ) );

// Make our attachement.
$id = $this->_test_img();
$srcset = tevkori_get_srcset_array( $id, 'medium' );

// The srcset should be false
$this->assertFalse( $srcset );

// Remove filter.
remove_filter( 'image_downsize', array( $this, '_test_tevkori_get_srcset_array_no_width_filter' ) );
}

/**
* Helper funtion to filter image_downsize and return zero values for width and height.
*/
public function _test_tevkori_get_srcset_array_no_width_filter() {
return array( 'http://example.org/foo.jpg', 0, 0, false );
}

function test_tevkori_get_srcset_string() {
// make an image
$id = $this->_test_img();
Expand Down
5 changes: 5 additions & 0 deletions wp-tevko-responsive-images.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ function tevkori_get_srcset_array( $id, $size = 'thumbnail' ) {
// Break image data into url, width, and height.
list( $img_url, $img_width, $img_height ) = $img;

// If we have no width to work with, we should bail (see issue #118).
if ( 0 == $img_width ) {
return false;
}

// Get the image meta data.
$img_meta = wp_get_attachment_metadata( $id );

Expand Down