- if (!empty($this->attachment->mimetype)) {
- switch ($this->attachment->mimetype) {
- case 'image/gif':
- case 'image/png':
- case 'image/jpg':
- case 'image/jpeg':
- try {
- // Tell getThumbnail that we can show an animated image if it has one (4th arg, "force_still")
- $thumb = $this->attachment->getThumbnail(null, null, false, false);
- $this->out->element('img', array('class'=>'u-photo', 'src' => $thumb->getUrl(), 'alt' => ''));
- } catch (UseFileAsThumbnailException $e) {
- $this->out->element('img', array('class'=>'u-photo', 'src' => $e->file->getUrl(), 'alt' => $e->file->title));
- } catch (UnsupportedMediaException $e) {
- // FIXME: Show a good representation of unsupported/unshowable images
- }
- break;
+ if (!empty($enclosure->mimetype)) {
+ // First, prepare a thumbnail if it exists.
+ $thumb = null;
+ try {
+ // Tell getThumbnail that we can show an animated image if it has one (4th arg, "force_still")
+ $thumb = $this->attachment->getThumbnail(null, null, false, false);
+ } catch (UseFileAsThumbnailException $e) {
+ $thumb = null;
+ } catch (UnsupportedMediaException $e) {
+ // FIXME: Show a good representation of unsupported/unshowable images
+ $thumb = null;
+ }
+
+ // Then get the kind of mediatype we're dealing with
+ $mediatype = common_get_mime_media($enclosure->mimetype);