diff options
| author | Marc Alexander <admin@m-a-styles.de> | 2015-02-08 20:46:14 +0100 |
|---|---|---|
| committer | Marc Alexander <admin@m-a-styles.de> | 2015-04-24 13:31:36 +0200 |
| commit | 2fa99602c6f6431e99468ca13f4a58344a401c24 (patch) | |
| tree | 0be2c3641e6f9b60d69130793484c8dfff5f932b /phpBB/phpbb/avatar/driver/gravatar.php | |
| parent | 746a33b57bf9bba645c826b596fbc54ee13d1954 (diff) | |
| download | forums-2fa99602c6f6431e99468ca13f4a58344a401c24.tar forums-2fa99602c6f6431e99468ca13f4a58344a401c24.tar.gz forums-2fa99602c6f6431e99468ca13f4a58344a401c24.tar.bz2 forums-2fa99602c6f6431e99468ca13f4a58344a401c24.tar.xz forums-2fa99602c6f6431e99468ca13f4a58344a401c24.zip | |
[ticket/8672] Add class for retrieving imagesize without download
getimagesize() always downloads the complete file before checking
the actual image dimensions. This class will be able to do the same
without having to download possibly large files.
PHPBB3-8672
Diffstat (limited to 'phpBB/phpbb/avatar/driver/gravatar.php')
| -rw-r--r-- | phpBB/phpbb/avatar/driver/gravatar.php | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/phpBB/phpbb/avatar/driver/gravatar.php b/phpBB/phpbb/avatar/driver/gravatar.php index 2082e0fd02..73effadc18 100644 --- a/phpBB/phpbb/avatar/driver/gravatar.php +++ b/phpBB/phpbb/avatar/driver/gravatar.php @@ -98,8 +98,8 @@ class gravatar extends \phpbb\avatar\driver\driver return false; } - // Make sure getimagesize works... - if (function_exists('getimagesize') && ($row['avatar_width'] <= 0 || $row['avatar_height'] <= 0)) + // Get image dimensions if they are not set + if ($row['avatar_width'] <= 0 || $row['avatar_height'] <= 0) { /** * default to the minimum of the maximum allowed avatar size if the size @@ -108,20 +108,20 @@ class gravatar extends \phpbb\avatar\driver\driver $row['avatar_width'] = $row['avatar_height'] = min($this->config['avatar_max_width'], $this->config['avatar_max_height']); $url = $this->get_gravatar_url($row); - if (($row['avatar_width'] <= 0 || $row['avatar_height'] <= 0) && (($image_data = getimagesize($url)) === false)) + if (($row['avatar_width'] <= 0 || $row['avatar_height'] <= 0) && (($image_data = $this->imagesize->get_imagesize($url)) === false)) { $error[] = 'UNABLE_GET_IMAGE_SIZE'; return false; } - if (!empty($image_data) && ($image_data[0] <= 0 || $image_data[1] <= 0)) + if (!empty($image_data) && ($image_data['width'] <= 0 || $image_data['width'] <= 0)) { $error[] = 'AVATAR_NO_SIZE'; return false; } - $row['avatar_width'] = ($row['avatar_width'] && $row['avatar_height']) ? $row['avatar_width'] : $image_data[0]; - $row['avatar_height'] = ($row['avatar_width'] && $row['avatar_height']) ? $row['avatar_height'] : $image_data[1]; + $row['avatar_width'] = ($row['avatar_width'] && $row['avatar_height']) ? $row['avatar_width'] : $image_data['width']; + $row['avatar_height'] = ($row['avatar_width'] && $row['avatar_height']) ? $row['avatar_height'] : $image_data['height']; } if ($row['avatar_width'] <= 0 || $row['avatar_height'] <= 0) |
