From d6245dca6347a670445701e9c726b0719ea945c8 Mon Sep 17 00:00:00 2001 From: Sean Murphy Date: Fri, 6 Feb 2009 18:36:34 -0500 Subject: [PATCH 1/3] Fixed #1048: Edit avatar link on profile page. --- actions/showstream.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/actions/showstream.php b/actions/showstream.php index eab1fc0a2d..3b4c97865b 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -245,6 +245,15 @@ class ShowstreamAction extends Action 'height' => AVATAR_PROFILE_SIZE, 'alt' => $this->profile->nickname)); $this->elementEnd('dd'); + + $user = User::staticGet('id', $this->profile->id); + $cur = common_current_user(); + if ($cur && $cur->id == $user->id) { + $this->elementStart('dd'); + $this->element('a', array('href' => common_local_url('avatarsettings')), _('Edit Avatar')); + $this->elementEnd('dd'); + } + $this->elementEnd('dl'); $this->elementStart('dl', 'entity_nickname'); @@ -317,7 +326,6 @@ class ShowstreamAction extends Action $this->element('h2', null, _('User actions')); $this->elementStart('ul'); $this->elementStart('li', array('class' => 'entity_subscribe')); - $cur = common_current_user(); if ($cur) { if ($cur->id != $this->profile->id) { if ($cur->isSubscribed($this->profile)) { @@ -335,7 +343,6 @@ class ShowstreamAction extends Action // common_profile_new_message_nudge($cur, $this->user, $this->profile); - $user = User::staticGet('id', $this->profile->id); if ($cur && $cur->id != $user->id && $cur->mutuallySubscribed($user)) { $this->elementStart('li', array('class' => 'entity_send-a-message')); $this->element('a', array('href' => common_local_url('newmessage', array('to' => $user->id)), From d90089314944ed1696f66cabbb6935ea61e4b2e6 Mon Sep 17 00:00:00 2001 From: Sean Murphy Date: Sat, 7 Feb 2009 10:01:08 -0500 Subject: [PATCH 2/3] Fixed #1152: Needless image scaling and poor JPG quality --- lib/imagefile.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/imagefile.php b/lib/imagefile.php index 74c3d14f03..faec7f0ff4 100644 --- a/lib/imagefile.php +++ b/lib/imagefile.php @@ -112,6 +112,23 @@ class ImageFile throw new Exception(_('Lost our file.')); return; } + + // Don't crop/scale if it isn't necessary + if ($size === $this->width + && $size === $this->height + && $x === 0 + && $y === 0 + && $w === $this->width + && $h === $this->height) { + + $outname = common_avatar_filename($this->id, + image_type_to_extension($this->type), + $size, + common_timestamp()); + $outpath = common_avatar_path($outname); + @copy($this->filepath, $outpath); + return $outname; + } switch ($this->type) { case IMAGETYPE_GIF: @@ -165,7 +182,7 @@ class ImageFile imagegif($image_dest, $outpath); break; case IMAGETYPE_JPEG: - imagejpeg($image_dest, $outpath); + imagejpeg($image_dest, $outpath, 100); break; case IMAGETYPE_PNG: imagepng($image_dest, $outpath); @@ -174,6 +191,9 @@ class ImageFile throw new Exception(_('Unknown file type')); return; } + + imagedestroy($image_src); + imagedestroy($image_dest); return $outname; } From 805560677bc66a58c270551fa54b613642b3af97 Mon Sep 17 00:00:00 2001 From: Sean Murphy Date: Sat, 7 Feb 2009 11:10:46 -0500 Subject: [PATCH 3/3] Fixed references to common_avatar_*. --- lib/imagefile.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/imagefile.php b/lib/imagefile.php index a8e9633708..ea24029a30 100644 --- a/lib/imagefile.php +++ b/lib/imagefile.php @@ -121,11 +121,11 @@ class ImageFile && $w === $this->width && $h === $this->height) { - $outname = common_avatar_filename($this->id, + $outname = Avatar::filename($this->id, image_type_to_extension($this->type), $size, common_timestamp()); - $outpath = common_avatar_path($outname); + $outpath = Avatar::path($outname); @copy($this->filepath, $outpath); return $outname; }