X-Git-Url: https://git.mxchange.org/?p=quix0rs-gnu-social.git;a=blobdiff_plain;f=lib%2Fattachmentlistitem.php;h=93dc4ca95e8840c3d9f4cb96d718400a9023a2fe;hp=3a9b005b2f01bfb87afbe79c0c502bfa414650ba;hb=e2d85a39e7f82ceef2cb2fe66a3a9a62ac9a363e;hpb=bc8e114b375bbe378440f2d33ea2577efade95b6 diff --git a/lib/attachmentlistitem.php b/lib/attachmentlistitem.php index 3a9b005b2f..93dc4ca95e 100644 --- a/lib/attachmentlistitem.php +++ b/lib/attachmentlistitem.php @@ -107,14 +107,20 @@ class AttachmentListItem extends Widget function showRepresentation() { if (Event::handle('StartShowAttachmentRepresentation', array($this->out, $this->attachment))) { if (!empty($this->attachment->mimetype)) { - switch ($this->attachment->mimetype) { - case 'image/gif': - case 'image/png': - case 'image/jpg': - case 'image/jpeg': + $mediatype = common_get_mime_media($this->attachment->mimetype); + + // FIXME: Get proper mime recognition of Ogg files! If system has 'mediainfo', this should do it: + // $ mediainfo --inform='General;%InternetMediaType%' + if ($this->attachment->mimetype === 'application/ogg') { + $mediatype = 'video'; // because this element can handle Ogg/Vorbis etc. on its own + } + switch ($mediatype) { + // Anything we understand as an image, if we need special treatment, do it in StartShowAttachmentRepresentation + case 'image': try { - $thumb = $this->attachment->getThumbnail(); - $this->out->element('img', array('class'=>'u-photo', 'src' => $thumb->getUrl(), 'alt' => '')); + // 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', $thumb->getHtmlAttrs(['class'=>'u-photo', 'alt' => ''])); } catch (UseFileAsThumbnailException $e) { $this->out->element('img', array('class'=>'u-photo', 'src' => $e->file->getUrl(), 'alt' => $e->file->title)); } catch (UnsupportedMediaException $e) { @@ -122,27 +128,9 @@ class AttachmentListItem extends Widget } break; - case 'application/ogg': - $arr = array('type' => $this->attachment->mimetype, - 'data' => $this->attachment->url, - 'width' => 320, - 'height' => 240 - ); - $this->out->elementStart('object', $arr); - $this->out->element('param', array('name' => 'src', 'value' => $this->attachment->url)); - $this->out->element('param', array('name' => 'autoStart', 'value' => 1)); - $this->out->elementEnd('object'); - break; - - case 'audio/ogg': - case 'audio/x-speex': - case 'video/mpeg': - case 'audio/mpeg': - case 'video/mp4': - case 'video/ogg': - case 'video/quicktime': - case 'video/webm': - $mediatype = common_get_mime_media($this->attachment->mimetype); + // HTML5 media elements + case 'audio': + case 'video': try { $thumb = $this->attachment->getThumbnail(); $poster = $thumb->getUrl(); @@ -155,22 +143,24 @@ class AttachmentListItem extends Widget 'poster'=>$poster, 'controls'=>'controls')); $this->out->element('source', - array('src'=>$this->attachment->url, + array('src'=>$this->attachment->getUrl(), 'type'=>$this->attachment->mimetype)); $this->out->elementEnd($mediatype); break; - case 'text/html': - if (!empty($this->attachment->filename) - && (StatusNet::isAjax() || common_config('attachments', 'show_html'))) { - // Locally-uploaded HTML. Scrub and display inline. - $this->showHtmlFile($this->attachment); - break; - } - // Fall through to default. - default: - Event::handle('ShowUnsupportedAttachmentRepresentation', array($this->out, $this->attachment)); + switch ($this->attachment->mimetype) { + case 'text/html': + if (!empty($this->attachment->filename) + && (GNUsocial::isAjax() || common_config('attachments', 'show_html'))) { + // Locally-uploaded HTML. Scrub and display inline. + $this->showHtmlFile($this->attachment); + break; + } + // Fall through to default if it wasn't a _local_ text/html File object + default: + Event::handle('ShowUnsupportedAttachmentRepresentation', array($this->out, $this->attachment)); + } } } else { Event::handle('ShowUnsupportedAttachmentRepresentation', array($this->out, $this->attachment));