diff options
Diffstat (limited to 'pages/avatar')
-rw-r--r-- | pages/avatar/view.php | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/pages/avatar/view.php b/pages/avatar/view.php index eb2cd1010..bd6c95821 100644 --- a/pages/avatar/view.php +++ b/pages/avatar/view.php @@ -3,6 +3,7 @@ * View an avatar */ +// page owner library sets this based on URL $user = elgg_get_page_owner_entity(); // Get the size @@ -13,33 +14,41 @@ if (!in_array($size, array('master', 'large', 'medium', 'small', 'tiny', 'topbar // If user doesn't exist, return default icon if (!$user) { - $url = "_graphics/icons/user/default{$size}"; + $url = "_graphics/icons/default/{$size}.png"; $url = elgg_normalize_url($url); forward($url); } +$user_guid = $user->getGUID(); + // Try and get the icon $filehandler = new ElggFile(); -$filehandler->owner_guid = $user->getGUID(); -$filehandler->setFilename("profile/" . $user->getGUID() . $size . ".jpg"); +$filehandler->owner_guid = $user_guid; +$filehandler->setFilename("profile/{$user_guid}{$size}.jpg"); $success = false; -if ($filehandler->open("read")) { - if ($contents = $filehandler->read($filehandler->size())) { - $success = true; + +try { + if ($filehandler->open("read")) { + if ($contents = $filehandler->read($filehandler->size())) { + $success = true; + } } +} catch (InvalidParameterException $e) { + elgg_log("Unable to get avatar for user with GUID $user_guid", 'ERROR'); } + if (!$success) { - $url = "_graphics/icons/user/default{$size}"; + $url = "_graphics/icons/default/{$size}.png"; $url = elgg_normalize_url($url); forward($url); } -header("Content-type: image/jpeg"); -header('Expires: ' . date('r', time() + 864000)); -header("Pragma: public"); -header("Cache-Control: public"); +header("Content-type: image/jpeg", true); +header('Expires: ' . date('r', strtotime("+6 months")), true); +header("Pragma: public", true); +header("Cache-Control: public", true); header("Content-Length: " . strlen($contents)); echo $contents; |