- return $thumbnail;
- }
- $enc = $this->attachment->getEnclosure();
- if ($enc) {
- switch ($enc->mimetype) {
- case 'image/gif':
- case 'image/png':
- case 'image/jpg':
- case 'image/jpeg':
- $thumb = (object)array();
- $thumb->url = $enc->url;
- // @fixme use the given width/height aspect
- $thumb->width = common_config('attachments', 'thumb_width');
- $thumb->height = common_config('attachments', 'thumb_height');
- return $thumb;
+ $maxWidth = common_config('attachments', 'thumb_width');
+ $maxHeight = common_config('attachments', 'thumb_height');
+ if ($thumbnail->width > $maxWidth) {
+ $thumb = clone($thumbnail);
+ $thumb->width = $maxWidth;
+ $thumb->height = intval($thumbnail->height * $maxWidth / $thumbnail->width);
+ return $thumb;