Is this an ideal use of if..else or can this code be simplified/beautified further?
// If any image found and bigger than thumbnail settings, get that one
if ( isset( $matches ) && !empty( $matches[1][0] ) ) {
$image_found = $matches[1][0];
$image_dimensions = getimagesize($image_found);
if ( ( $image_dimensions[0] > $width ) && ( $image_dimensions[1] > $height ) ) {
$thumbnail_img = $matches[1][0];
}
// Check 2nd image found
else if ( !empty( $matches[1][1] ) ) {
$image_found = $matches[1][1];
$image_dimensions = getimagesize($image_found);
if ( ( $image_dimensions[0] > $width ) && ( $image_dimensions[1] > $height ) ) {
$thumbnail_img = $matches[1][1];
}
// Check 3rd image found
else if ( !empty( $matches[1][2] ) ) {
$image_found = $matches[1][2];
$image_dimensions = getimagesize($image_found);
if ( ( $image_dimensions[0] > $width ) && ( $image_dimensions[1] > $height ) ) {
$thumbnail_img = $matches[1][2];
}
}
}
}