MediaWiki:Common.js/file.js
Jump to navigation
Jump to search
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/* <source lang="javascript"><nowiki> */ // SVG images: adds links to rendered PNG images in different resolutions function SVGThumbs() { if (wgAction == "view" && wgNamespaceNumber == 6 && wgTitle.substring(wgTitle.lastIndexOf(".")).toLowerCase() == ".svg") { var file = document.getElementById("file"); if (!file) return; // might happen if MediaWiki can't render the SVG var div = document.createElement("div"); div.appendChild(document.createTextNode("SVG rendered as PNG images in different resolutions:")); var a200 = document.createElement("a"); a200.setAttribute("href", "http://commons.wikimedia.org/w/thumb.php?f=" + encodeURIComponent(wgTitle) + "&width=200px&height=200px"); a200.appendChild(document.createTextNode("200px")); var a500 = document.createElement("a"); a500.setAttribute("href", "http://commons.wikimedia.org/w/thumb.php?f=" + encodeURIComponent(wgTitle) + "&width=500px&height=500px"); a500.appendChild(document.createTextNode("500px")); var a1000 = document.createElement("a"); a1000.setAttribute("href", "http://commons.wikimedia.org/w/thumb.php?f=" + encodeURIComponent(wgTitle) + "&width=1000px&height=1000px"); a1000.appendChild(document.createTextNode("1000px")); var a2000 = document.createElement("a"); a2000.setAttribute("href", "http://commons.wikimedia.org/w/thumb.php?f=" + encodeURIComponent(wgTitle) + "&width=2000px&height=2000px"); a2000.appendChild(document.createTextNode("2000px")); div.appendChild(a200); div.appendChild(document.createTextNode(", ")); div.appendChild(a500); div.appendChild(document.createTextNode(", ")); div.appendChild(a1000); div.appendChild(document.createTextNode(", ")); div.appendChild(a2000); div.appendChild(document.createTextNode(".")); file.parentNode.insertBefore(div, document.getElementById("file").nextSibling.nextSibling); } }; addOnloadHook( SVGThumbs ) /* </nowiki></source> */