Page MenuHomePhabricator

MediaWiki's Media Viewer extension offers to "Open in Media Viewer" for unsupported types
Closed, ResolvedPublic

Description

I understand that PDF, MP3 file types are not supported yet. If so, I would suggest to *not* offer the "Open in Media Viewer" button in the file page for such unsupported files, because at the moment all I see is a rather confusing error message:

Sorry, the file cannot be displayed
There seems to be a technical issue. You can retry or report the issue if it persists.
Error: File does not exist: File:Fileicon-pdf.png

Note that the file I was trying to open has a completely different name, so the file does exist (I can download it), but the error is bogus. Thanks.

Related Objects

Event Timeline

Restricted Application added subscribers: Zppix, Aklapper. · View Herald TranscriptJun 9 2016, 8:01 PM
Tgr added a subscriber: Tgr.Jun 9 2016, 8:33 PM

The buttons are added by MultimediaViewerBootstrap's processFilePageThumb method. That method is preceded by an if ( !( title.getExtension().toLowerCase() in bs.validExtensions ) ) guard condition. So either you use a very outdated version of MediaViewer, or you have changed the valid extensions list (which should eventually come from $wgMediaViewerExtensions).

I have just downloaded and installed MultimediaViewer (0.3.0).
I did add some extensions at the bottom of my LocalSettings.php so I could upload the files. Here's the custom (bottom) part of LocalSettings.php:

# Add new types to the existing list from DefaultSettings.php
$wgFileExtensions[] = 'docx';
$wgFileExtensions[] = 'xls';
$wgFileExtensions[] = 'pdf';
$wgFileExtensions[] = 'mpp';
$wgFileExtensions[] = 'odt';
$wgFileExtensions[] = 'ods';
$wgFileExtensions[] = 'doc';
$wgFileExtensions[] = 'rtf';
$wgFileExtensions[] = 'mp3';

# Additional extensions
require_once "$IP/extensions/NoTOC/NoTOC.php";

require_once "$IP/extensions/UserMerge/UserMerge.php";
// By default nobody can use this function, enable for bureaucrat
$wgGroupPermissions['bureaucrat']['usermerge'] = true;

wfLoadExtension( 'MsUpload' );

require_once "$IP/extensions/MultimediaViewer/MultimediaViewer.php";
wfLoadExtension( 'CommonsMetadata' );

Did I do it wrong?

Tgr added a comment.Jun 9 2016, 9:06 PM

No, that seems fine. Where did you get MediaViewer from? The version number is defunct (has not been incremented for years), so that might or might not be a recent version.

From this page, go to the "Code" section, it will take you here (and here).
OK so let's start from scratch. How do I download and install the latest Media Viewer? It's not obvious from the page linked above, apart from those two links...
Thanks!

Tgr added a comment.Jun 9 2016, 9:19 PM

Those links are fine. On the extension pages, select the "Download snapshot" link, select your MediaWiki version and download the tarball.

Yep, that's what I have done, I still have the tarball in my extensions directory:

MultimediaViewer-REL1_26-a312b66.tar.gz

My Special:Version page indicates "MultimediaViewer 0.3.0" though...!
Thanks much for your help.

$ cat extensions/MultimediaViewer/version
MultimediaViewer: a312b66de94cb2f1c1f1b33ee3bd3af1f41ef06c

2016-01-09T23:04:13

a312b66
Tgr added a comment.Jun 9 2016, 10:05 PM

That sounds reasonably recent, it should definitely ignore unknown extensions.

Could you open your browser console and check the value of mw.config.values.wgMultimediaViewer.extensions in Javascript?

My Special:Version page indicates "MultimediaViewer 0.3.0" though...!

Uh. We should probably get rid of that.

Change 293630 had a related patch set uploaded (by Gergő Tisza):
Get rid of version number

https://gerrit.wikimedia.org/r/293630

mw.config.values.wgMultimediaViewer does not have an extensions... are you sure?

Tgr added a comment.Jun 9 2016, 10:47 PM

Hm, no, it's hardcoded in that version. Even weirder. You'll probably have to debug why this part does not work as expected.

I think what's happening is that the "Open in Media Viewer" button does not refer to the PDF, but to the image of the PDF icon (Fileicon-pdf.png), which explains why the extension is valid and that test passes.
It's still a mystery why the viewer then fails to find the icon (hence the error), but the root cause here is that the icon makes that "Open" button appear.

In fact, could this be? The file actually starts with a lowercase "f", that's why the viewer cannot find it

resources/assets/file-type-icons/fileicon-pdf.png

Anyway, like I said this is secondary.

Tgr added a comment.Jun 9 2016, 11:06 PM

I see, thanks for figuring that out. Could you paste the contents of the #file div?

Sure (pretty-printed):

<div class="fullImageLink" id="file">
  <a href="/wiki/images/8/89/MyFilename.PDF">
    <img alt="" src="/wiki/resources/assets/file-type-icons/fileicon-pdf.png"
      width="120" height="120" data-file-width="0" data-file-height="0" />
  </a>
</div>

I should add that doc, docx, and rtf files do not have that problem.

Here's the same div for mp3 files (which *do* have the same problem):

<div class="fullImageLink" id="file">
  <a href="/wiki/images/2/21/MyFilename.mp3">
    <img alt="" src="/wiki/resources/assets/file-type-icons/fileicon.png" width="120"
      height="120" data-file-width="0" data-file-height="0" />
  </a>
</div>
Tgr added a comment.EditedJun 10 2016, 8:54 AM

Ah, I see. I didn't get that error because the icon is only used if you don't have PDFHandler installed. (And the file is not found because it's an asset, not an uploaded file.)

Cool thanks.
So am I right in thinking that:

  1. It's confirmed to be a bug
  2. There is a work-around for PDFs (install PDFHandler)
  3. There is no work-around for other files, namely MP3
Tgr added a comment.Jun 10 2016, 9:23 AM

Yes. Installing an MP3 handler might work around it.

Change 293695 had a related patch set uploaded (by Gergő Tisza):
Fix title detection on file pages

https://gerrit.wikimedia.org/r/293695

Tgr added a comment.Jun 10 2016, 9:34 AM

Or you can test the patch above.

Change 293630 merged by jenkins-bot:
Get rid of version number

https://gerrit.wikimedia.org/r/293630

Jdlrobson added a subscriber: Jdlrobson.

https://gerrit.wikimedia.org/r/#/c/293695/is currently -1ed. Please remove Patch-Needs-Improvement when you are ready for us to have another look.

dr0ptp4kt triaged this task as Normal priority.Apr 18 2017, 3:23 PM
dr0ptp4kt moved this task from Backlog to Next on the MediaViewer board.
MarkTraceur added a subscriber: MarkTraceur.

Updated patch, @Jdlrobson if you want to take another look that would be nice

MarkTraceur moved this task from Next to In Process on the MediaViewer board.Apr 19 2017, 1:19 PM
Krinkle removed a subscriber: Krinkle.Sep 25 2017, 5:10 PM
Ramsey-WMF moved this task from Untriaged to Tracking on the Multimedia board.Oct 6 2017, 11:05 PM

Change 293695 merged by jenkins-bot:
[mediawiki/extensions/MultimediaViewer@master] Fix title detection on file pages

https://gerrit.wikimedia.org/r/293695

ABorbaWMF closed this task as Resolved.Nov 27 2017, 5:26 PM
ABorbaWMF claimed this task.
ABorbaWMF added a subscriber: ABorbaWMF.

Tested on Beta and I do not see the Open in mediaviewer button present on PDF files and an error on MP3.