- $avatar = $this->_getAvatar($width);
-
- if (empty($avatar)) {
- if (Event::handle('StartProfileGetAvatar', array($this, $width, &$avatar))) {
- $avatar = Avatar::pkeyGet(
- array(
- 'profile_id' => $this->id,
- 'width' => $width,
- 'height' => $height
- )
- );
- Event::handle('EndProfileGetAvatar', array($this, $width, &$avatar));
- }
-
- // if-empty within an if-empty? Let's find a prettier solution...
- if (empty($avatar)) {
- // Obviously we can't find an avatar, so let's resize the original!
- try {
- $avatar = Avatar::newSize($this, $width);
- } catch (Exception $e) {
- // Could not generate a resized avatar. How do we handle it?
- }
- }
+ try {
+ return $this->_getAvatar($width);
+ } catch (Exception $e) {
+ $avatar = null;
+ }
+
+ if (Event::handle('StartProfileGetAvatar', array($this, $width, &$avatar))) {
+ $avatar = Avatar::pkeyGet(
+ array(
+ 'profile_id' => $this->id,
+ 'width' => $width,
+ 'height' => $height
+ )
+ );
+ Event::handle('EndProfileGetAvatar', array($this, $width, &$avatar));
+ }