Extension:MultimediaViewer

From MediaWiki.org
Jump to: navigation, search

Other languages:
English • ‎español • ‎日本語 • ‎Nederlands • ‎polski • ‎русский • ‎中文
shortcut: MV
MediaWiki extensions manual
Crystal Clear action run.png
MultimediaViewer

Release status: stable

Screenshot of MultimediaViewer extension 2014-04-21.png
Implementation User interface, Ajax
Description Provides a better experience to users when they click on thumbnails in a page
Author(s) Mark Holmquist, Gergő Tisza, Gilles Dubuc
Latest version 0.3.0 (2014-03-28)
MediaWiki 1.23+
PHP 5.3+
Database changes No
License GPL-2.0+
Download
Example MediaWiki.org
Namespace main
Parameters
  • $wgEnableMediaViewerForLoggedInUsersOnly
  • $wgMediaViewerIsInBeta
Hooks used
GetBetaFeaturePreferences

BeforePageDisplay
CategoryPageView
ResourceLoaderGetConfigVars

Translate the MultimediaViewer extension if it is available at translatewiki.net

Check usage and version matrix; code metrics
Bugs: list open list all report

The MultimediaViewer extension gives the user of a wiki a different interface for viewing full-size, or nearly full-size, images in their browser without extraneous page loads or confusing interstitial pages.

Installation[edit | edit source]

Option A: use Vagrant. See the MediaWiki-Vagrant page for instructions to get a MediaWiki installation going with a Vagrant virtual machine system.

Then do vagrant enable-role multimediaviewer and then vagrant provision.

Option B: install manually.

First, consider installing Extension:BetaFeatures. It may be helpful to hide the media viewer feature behind a preference. If you don't install this, it will be enabled everywhere. MultimediaViewer uses the GetBetaFeaturePreferences hook, which is created and run from BetaFeatures, to register this preference.

You'll also likely want to download Extension:CommonsMetadata - it's not a hard requirement, but without it you won't get very much information in your lightboxes.

  • Download and extract the file(s) in a directory called MultimediaViewer in your extensions/ folder. If you're a developer and this extension is in a Git repository, then instead you should clone the repository using:
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/MultimediaViewer.git
  • Add the following code at the bottom of your LocalSettings.php:
require_once "$IP/extensions/MultimediaViewer/MultimediaViewer.php";
  • Done! Navigate to "Special:Version" on your wiki to verify that the extension is successfully installed.

Configuration[edit | edit source]

  • $wgMediaViewerIsInBeta will register a preference with BetaFeatures if set to "true"
  • $wgEnableMediaViewerForLoggedInUsersOnly will turn MMV on for only logged-in users if set to "true"
  • $wgMediaViewerUseThumbnailGuessing set to "false" may be needed if you do not have a 404 handler. This can still fail as of June 2014; a handler is recommended.

If neither $wgMediaViewerIsInBeta nor $wgEnableMediaViewerForLoggedInUsersOnly are set, MMV will be turned on for all users!

Forced download

To ensure files are offered for download and not viewed in the user's browser following a click on the Download … button, the server has to be configured, except when using vagrant:

If the requested URL to an image directory contains the download query parameter, the Content-Disposition-header must be set to attachment. This can be achieved in Apache and compatible servers using mod_rewrite and mod_headers in a .htaccess file. Varnish configuration can look like this.

Using the extension[edit | edit source]

First thing, before testing, is to make sure you're logged in and you have the preference enabled: Log in to the wiki and go to Special:Preferences, then visit the "Beta features" tab and check the appropriate box.

Next, go to a page that has a thumbnail on it. Try clicking on the image or on the "expand" icon near it. The lightbox should pop up and give you a bigger view of the image.

If you'd prefer, there's an exported test environment that you can use via Special:Import to quickly set up a suitable testing environment.

Extending with user scripts[edit | edit source]

If you want to add functionality, you'll have to dig around in the classes and change the functionality pretty manually. We'll work on making this a nicer experience, but given the class and method hierarchy we've built, we think it's not terribly difficult right now.

HOWEVER, you should avoid doing this too much. If things change internally, then your code might break in unexpected ways, and you (and your users) will be surprised. Don't let that happen, and wait for a more stable way to extend the product.

See /Extension:Metadata for an example.

See also[edit | edit source]