Actually show all images as <img /> tags.

Browsers should be secure enough by now for this.
This commit is contained in:
Mikael Nordfeldth 2015-03-05 11:59:31 +01:00
parent 3755faf558
commit 72015d499f

View File

@ -107,11 +107,10 @@ class AttachmentListItem extends Widget
function showRepresentation() { function showRepresentation() {
if (Event::handle('StartShowAttachmentRepresentation', array($this->out, $this->attachment))) { if (Event::handle('StartShowAttachmentRepresentation', array($this->out, $this->attachment))) {
if (!empty($this->attachment->mimetype)) { if (!empty($this->attachment->mimetype)) {
switch ($this->attachment->mimetype) { $mediatype = common_get_mime_media($this->attachment->mimetype);
case 'image/gif': switch ($mediatype) {
case 'image/png': // Anything we understand as an image, if we need special treatment, do it in StartShowAttachmentRepresentation
case 'image/jpg': case 'image':
case 'image/jpeg':
try { try {
// Tell getThumbnail that we can show an animated image if it has one (4th arg, "force_still") // 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); $thumb = $this->attachment->getThumbnail(null, null, false, false);
@ -123,27 +122,9 @@ class AttachmentListItem extends Widget
} }
break; break;
case 'application/ogg': // HTML5 media elements
$arr = array('type' => $this->attachment->mimetype, case 'audio':
'data' => $this->attachment->url, case 'video':
'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);
try { try {
$thumb = $this->attachment->getThumbnail(); $thumb = $this->attachment->getThumbnail();
$poster = $thumb->getUrl(); $poster = $thumb->getUrl();
@ -156,22 +137,36 @@ class AttachmentListItem extends Widget
'poster'=>$poster, 'poster'=>$poster,
'controls'=>'controls')); 'controls'=>'controls'));
$this->out->element('source', $this->out->element('source',
array('src'=>$this->attachment->url, array('src'=>$this->attachment->getUrl(),
'type'=>$this->attachment->mimetype)); 'type'=>$this->attachment->mimetype));
$this->out->elementEnd($mediatype); $this->out->elementEnd($mediatype);
break; break;
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.
default: default:
Event::handle('ShowUnsupportedAttachmentRepresentation', array($this->out, $this->attachment)); switch ($this->attachment->mimetype) {
// Ogg media that we're not really sure what it is...
case 'application/ogg':
$arr = array('type' => $this->attachment->mimetype,
'data' => $this->attachment->getUrl(),
'width' => 320,
'height' => 240
);
$this->out->elementStart('object', $arr);
$this->out->element('param', array('name' => 'src', 'value' => $this->attachment->getUrl()));
$this->out->element('param', array('name' => 'autoStart', 'value' => 1));
$this->out->elementEnd('object');
break;
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 { } else {
Event::handle('ShowUnsupportedAttachmentRepresentation', array($this->out, $this->attachment)); Event::handle('ShowUnsupportedAttachmentRepresentation', array($this->out, $this->attachment));