Skip to content

Commit

Permalink
Prevent "Division by zero" in avatar functions.
Browse files Browse the repository at this point in the history
Part of #1492
  • Loading branch information
benlk committed Nov 28, 2018
1 parent 3e09306 commit 02697be
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 02697be

Please sign in to comment.