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.

openpdfinmediaviewer.png (411×552 px, 22 KB)

openpdfinmediaviewer2.png (529×800 px, 29 KB)

Related Objects

Event Timeline

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?

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!

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

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?

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.

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>

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

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

Or you can test the patch above.

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

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

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

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

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

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

ABorbaWMF claimed this task.
ABorbaWMF subscribed.

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

Screen Shot 2017-11-27 at 9.25.38 AM.png (1×2 px, 1 MB)

Screen Shot 2017-11-27 at 9.19.09 AM.png (882×2 px, 112 KB)