Skip to content

Commit

Permalink
Merge pull request #173 from joemcgill/single-arrays
Browse files Browse the repository at this point in the history
Return single source candidates in `tevkori_get_srcset_array()`
  • Loading branch information
joemcgill committed Sep 18, 2015
2 parents 27d54da + 78ee139 commit 3e97142
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
7 changes: 4 additions & 3 deletions tests/test-suite.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,15 @@ function test_tevkori_get_srcset_array_no_date_upoads() {
update_option( 'uploads_use_yearmonth_folders', $uploads_use_yearmonth_folders );
}

function test_tevkori_get_srcset_array_single_srcset() {
function test_tevkori_get_srcset_single_srcset() {
// make an image
$id = $this->_test_img();
// In our tests, thumbnails would only return a single srcset candidate,
// in which case we don't bother returning a srcset array.
$sizes = tevkori_get_srcset_array( $id, 'thumbnail' );
$sizes = tevkori_get_srcset( $id, 'thumbnail' );

$this->assertFalse( $sizes );
$this->assertTrue( 1 === count( tevkori_get_srcset_array( $id, 'thumbnail' ) ) );
$this->assertFalse( tevkori_get_srcset( $id, 'thumbnail' ) );
}

/**
Expand Down
6 changes: 1 addition & 5 deletions wp-tevko-responsive-images.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,6 @@ function tevkori_get_srcset_array( $id, $size = 'thumbnail' ) {
}
}

if ( count( $arr ) <= 1 ) {
return false;
}

/**
* Filter the output of tevkori_get_srcset_array().
*
Expand All @@ -260,7 +256,7 @@ function tevkori_get_srcset_array( $id, $size = 'thumbnail' ) {
function tevkori_get_srcset( $id, $size = 'thumbnail' ) {
$srcset_array = tevkori_get_srcset_array( $id, $size );

if ( empty( $srcset_array ) ) {
if ( count( $srcset_array ) <= 1 ) {
return false;
}

Expand Down

0 comments on commit 3e97142

Please sign in to comment.