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" && 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("p"); div.appendChild(document.createTextNode("This image rendered as PNG in some sizes"+": ")); var a200 = document.createElement("a"); a200.setAttribute("href", wgServer + wgScriptPath + "/thumb.php?f=" + encodeURIComponent(wgTitle) + "&width=200px&height=200px"); a200.appendChild(document.createTextNode("200px")); var a500 = document.createElement("a"); a500.setAttribute("href", wgServer + wgScriptPath + "/thumb.php?f=" + encodeURIComponent(wgTitle) + "&width=500px&height=500px"); a500.appendChild(document.createTextNode("500px")); var a1000 = document.createElement("a"); a1000.setAttribute("href", wgServer + wgScriptPath + "/thumb.php?f=" + encodeURIComponent(wgTitle) + "&width=1000px&height=1000px"); a1000.appendChild(document.createTextNode("1000px")); var a2000 = document.createElement("a"); a2000.setAttribute("href", wgServer + wgScriptPath + "/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(".")); var info = getElementsByClassName( file.parentNode, 'div', 'fullMedia' )[0]; if( info ) info.appendChild(div); } }; addOnloadHook( SVGThumbs ) /* </nowiki></source> */