Extension:Proofread Page/Page viewer


The ProofreadPage extension uses the popular OpenSeadragon (OSD) library to provide a zoomable image viewer in the Page namespace and the Pagelist editor. This provides various useful features:

  • A well-known and robust JS API for script and gadget extensibility
  • Zoom and panning that works on desktop and mobile
  • A well-maintained upstream codebase

OpenSeadragon replaced the previous home-made jQuery implementation in release 1.38.0-wmf.9.

Using the viewerEdit

The main viewport controls are found on the top right of the image viewer:


From left to right:

  •   Select a region of the image for OCR (not merged yet)
  •   Add a moveable guide (not merged yet)
  • Zoom in, out and reset zoom to the full page
  •     Rotate the image by 90 degrees left or right

Mouse navigationEdit

Some of these features are not merged yet: Gerrit change 740369

You can scroll and zoom the image as follows:

  • Left click and drag: pan the image
  • Scroll wheel: zoom the image in and out
  • Ctrl+scroll: pan the image up and down
  • Shift+scroll: pan the image side to side
  • Left click: zoom in one step
  • Shift+Left click: zoom out one step

The middle mouse button switches the normal and Ctrl-key modes (so Ctrl+scroll becomes zoom and normal scroll becomes pan). The cursor changes to identify which mode you are in.

Keyboard navigationEdit

The default OpenSeadraon keyboard bindings are used:

  • w, up arrow — move viewport up
  • s, down arrow — move viewport down
  • a, left arrow — move viewport left
  • d, right arrow — move viewport right
  • 0 — zoom / move viewport home
  • - _, Shift+W, Shift+up arrow — zoom viewport out
  • =, +, Shift+S, Shift+down arrow — zoom viewport in
  • r — rotate clockwise
  • R — rotate counterclockwise

Marker linesEdit

Not merged yet

The button   can be used to add a moveable guide.

  • Click the button to add a guide to the image.
  • Drag a guide to move it
  • Double-click a guide to delete it

Guides will persist when you reload the page, so they can be used to help keep your place while previewing your changes.

Viewer optionsEdit

There are some options for the page viewer in your preferences, in the Editing tab, under the Proofreading interface options heading.

Animation speed
This makes the panning and zoom feel smoother. The default is '0', which means there is zero lag and the zoom "snaps" from one level to the next. The OSD default used on many third-party image viewers is 1.2.
Zoom step of the viewer
This adjusts how "fast" the viewer zooms in and out. The default is 1.2. If you find the zoom too aggressive, you could try to lower it to, say, 1.1.



The following mw.hooks are fired:

Hook Description Arguments
ext.proofreadpage.osd-viewer-ready Fired when the OpenSeadragon viewer is ready and an image is loaded.
  • Argument 1: viewer the OpenSeadragon viewer object (also available as mw.proofreadpage.viewer)


The following objects are presented in the mw.proofreadpage global object:


The OpenSeadragon viewer object. Only valid after ext.proofreadpage.osd-viewer-ready.

This can change, e.g. after the viewer is swapped from horizontal to vertical mode.


Pending review: Gerrit change 736203

Returns a jQuery object that holds a <div> that contains controls for the viewer, which is placed in the WikiEditor toolbar. Scripts can add new controls to this area. Only valid after ext.proofreadpage.osd-viewer-ready.

Config variablesEdit

The following mw.config variables are added to Page namespace pages. These can be used by gadgets and user scripts.

Variable Content Type Example
prpFormattedPageNumber The formatted page number (usually what's actually written on the page) string "20"
prpImageFullSize The URL of the full-size page image (the largest image of the current page) string "//upload.wikimedia.org/wikipedia/commons/thumb/a/a8/My_mortal_enemy_-_1926.djvu/page20-3893px-My_mortal_enemy_-_1926.djvu.jpg"
prpImageThumbnail The URL of the thumbnail page image (the size used in the page viewer) string "//upload.wikimedia.org/wikipedia/commons/thumb/a/a8/My_mortal_enemy_-_1926.djvu/page20-1024px-My_mortal_enemy_-_1926.djvu.jpg"
prpIndexFields The values of any index fields in the index data config object marked js: true object { Progress: "C", Transclusion: "no", Footer: "\n", … }
prpIndexTitle The name of the associated index page string "Index:My mortal enemy - 1926.djvu"
prpPageQuality The current quality level of the page (0-4, 1 if the page doesn't exist yet) integer 1
prpPageQualityUser The name of the last user to set the quality string "SomeUser"

Use by scripts and gadgetsEdit

Scripts and gadgets can use the API for anything supported by the OpenSeadragon API via the mw.proofreadpage.viewer object.

Changing the imageEdit

The image can be changed by adding an image to the viewer.

For "simple" images (i.e. where you have just an image URL):

mw.hook( 'ext.proofreadpage.osd-viewer-ready' ).add( function ( viewer ) {
    // Can use viewer or mw.proofreadpage.viewer - they're the same
        .addSimpleImage( {
            url: image_url
        } );
} );

You can also directly add an IIIF tiled image source:

	.addTiledImage( {
		tileSource: iiif_json_url
	} );

Adding buttons to the viewport control toolbarEdit

These can be directly added to the element returned by mw.proofreadpage.getPageViewportControls():

var button = new OO.ui.ButtonWidget( {
	icon: 'home', // choose an icon
	framed: false,
	classes: [ 'tool' ]
} );

mw.proofreadpage.getPageViewportControls().append( button );

Tools do not have to go in this toolbar to interact with the OpenSeadragon viewer; they can also go in the sidebar, the normal toolbar (for which the WikiEditor toolbar configuration system can be used) or anywhere else in the DOM.

Region selectionEdit

This is not merged yet Gerrit change 741125

A region selection module (ext.proofreadpage.page.regionselection) is provided that allows scripts to add a simple rectangular region selection.

The region selection is communicated by OOUI events. Intantiate a region selector and bind handlers like this:

mw.loader.using( 'ext.proofreadpage.page.regionselection', function( require ) {
    var RegionSelection = require( 'ext.proofreadpage.page.regionselection' );
    var regionSelector = new RegionSelection();
    mw.hook( 'ext.proofreadpage.osd-viewer-ready' ).add( function ( viewer ) {
        regionSelector.register( viewer );
        regionSelector.connect( this, {
            [ regionSelector.events.selectionStart ]: [ 'onRegionToggle', true ],
            [ regionSelector.events.selectionEnd ]: [ 'onRegionToggle', false ]
	    } );
    } );
    // start a selection
    regionSelector.toggleSelection( true );
} );

In this case onRegionToggle is a handler that you should provide.


  • selectionStart emitted when a selection starts
  • selectionEnd emitted when a selection ends (the selection is cancelled somehow)

Methods on a RegionSelector:

  • isActive() if a selection is active now
  • getSelection() get the selection rectangle in a co-ordinate system from 0 to 1

See alsoEdit