Extension:ImagePagePrintLink
|
Image Page Print Link Release status: beta |
|||
|---|---|---|---|
| Implementation | User interface | ||
| Description | Adds a link for printing the image at every local image description page. | ||
| Author(s) | Säsongsmat.nu (RotseeTalk) | ||
| Last version | 0.4 (2012-01-08) | ||
| MediaWiki | 1.18.0+ | ||
| PHP | 5 | ||
| License | BSD | ||
| Download | zip or tar.gz | ||
| Example | Printable file | ||
|
|||
|
Check usage (experimental) |
|||
ImagePagePrintLink will add a ”print this image” link to the list of links in the top of a image descriptions page. Printing is done using JavaScript, and the link will be visible only if JavaScript is enabled and printing is supported. Link will only show up for local files, as most browsers will not allow javascript to print from other domains, and only if the file is a (seemingly) printable image.
This extension was written for Säsongsmat.nu, Please feel free to improve or change anything if you feel you could use it somewhere else.
Contents |
[edit] Requirements
Current version requires MediaWiki 1.18. Version 0.2 (see below) should work with anything > 1.16.0. Please add a line here if you try it with a different version. (Earlier versions will most likely not work.)
[edit] Installation
Download the extension (zip | tar.gz), unpack it and put it in your extensions directory.
Add the following to LocalSettings.php:
require_once("$IP/extensions/ImagePagePrintLink/ImagePagePrintLink.php");
[edit] Versions
- 0.4
- Now requires MW >= 1.18
- Replaced wgOut with getContext.
- Only add module on local files
- 0.3
- Now requires MW >= 1.17
- ja translation
- added title-attribute
- using Resource loader
- 0.2
- load jquery if not loaded
- use i18n for description
- use add extensions name to i18n parameter names
- 0.1
- First version
[edit] To do
- Find a better way to handle Google Chrome printing issues in ext.ImagePagePrintLink.core.js. Chrome will close the window imediately, and then try to print an empty page. Therefore, the image page is not closed again if js detects Chrome. This is an ugly workaround, would be nice to get rid of it.
- Use something more acurate than canRender to check if media is image?
[edit] Old versions
For MW < 1.17 you can use version 0.2: ImagePagePrintLink_0.2.zip · ImagePagePrintLink_0.2.tar.gz You will then have to manually add the following JavaScript snippet to your MediaWiki:Common.js (default for most skins), or where ever you have your Javascripts.
jQuery(document).ready(function($) { if (window.print) { $("#printthisimage").click(function() { var printthisimagewindow = window.open($("#printthisimage").attr("data-href")); //use timeout testing, as many browsers (e.g. IE) will not have created a window object at this point var testdocbody; function printWinLoaded(){ testdocbody = printthisimagewindow.document.getElementsByTagName("body"); if(testdocbody[0]==null){ setTimeout(printWinLoaded, 10); }else{ printthisimagewindow.print(); printthisimagewindow.close(); } } printWinLoaded(); return false; }); //Remove hidden style. $("#printthisimage").css("display",""); } });
[edit] Source code
You can browse the source code of version 0.4 here:
- ImagePagePrintLink/
- ImagePagePrintLink/js/
