Skip to content

Commit

Permalink
Merge pull request #1578 from INN/1492-avatar-divide-by-zero
Browse files Browse the repository at this point in the history
Prevent "Division by zero" in avatar functions.
  • Loading branch information
benlk authored Nov 28, 2018
2 parents 187eca0 + ec80f6e commit a182c52
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion inc/avatars/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,19 @@ function largo_get_avatar_src( $id_or_email, $size ) {
});

$square_image_sizes = array_filter( $copy, function( $arg ) {
return ( $arg['width'] / $arg['height'] ) == 1;
// a function to filter whether the image size is square
if (
( isset( $arg['width'] ) && isset( $arg['height'] ) )
&&
( is_numeric( $arg['width'] ) && is_numeric( $arg['height'] ) )
&&
( $arg['width'] > 0 && $arg['height'] > 0 )
) {
$divided = $arg['width'] / $arg['height'];
return ( $divided == 1 );
} else {
return false;
}
} );

$requested_size = array( $size, $size );
Expand Down

0 comments on commit a182c52

Please sign in to comment.