Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// Add thumbnails to IfD pages; see the talk page for documentation.if(/^(Wikipedia:((Files|Images_and_media)_for_deletion|Possibly_unfree_(files|images))|Commons:Deletion_requests)(\/|$)/.test(mw.config.get('wgPageName'))){varhTag=(mw.config.get('wgDBname')=="commonswiki"?"h3":"h4");mw.util.addCSS("a.ifd-thumbnail { display: block; float: right; }\n"+"a.ifd-thumbnail img { border: 1px solid #ccc; margin: 0 0 0.5em 1em; }\n"+hTag+", div.delh { clear: right; }\n");varcreateThumbnails=function(){// compile a list of images being discussed and save the heading node for eachvarheadings=document.getElementsByTagName(hTag);varimages=[];varimageLocations={};for(vari=0;i<headings.length;i++){varlinks=headings[i].getElementsByTagName("a");for(varj=0;j<links.length;j++){if(!/^(Image|File):/i.test(links[j].title)||/(^|\s)new(\s|$)/.test(links[j].className))continue;images.push(links[j].title);imageLocations[links[j].title]=headings[i];break;}}if(!images.length)return;// nothing to do :-/headings=null;// free DOM nodeList, we're done with it// make an API request to find URLs for each imagevarshowThumbnails=function(result){// parse JSON outputif(result.error)return;// alert("API error " + result.error.code + ": " + result.error.info);if(!result.query||!result.query.pages)return;// alert("Unexpected API result:\n" + ajax_result.responseText);// hopefully we don't get any normalization, but just in case...if(result.query.normalized){varnorm=result.query.normalized;for(vari=0;i<norm.length;i++){imageLocations[norm[i].to]=imageLocations[norm[i].from];}}// now loop over the result and insert thumbsvarpages=result.query.pages;for(varidinpages){vartitle=pages[id].title;if(!title)continue;// should not happenif(pages[id].imagerepository&&pages[id].imagerepository=="shared")continue;// don't show thumbnails for Commons images (which may show up on IfD after a local copy has been deleted)varinfo=pages[id].imageinfo;if(!info||!info.length)continue;// can happen if the image has been deletedinfo=info[0];if(!info.thumburl||!info.thumbwidth||!info.thumbheight||!info.descriptionurl)continue;// should not happenvarheading=imageLocations[title];if(!heading)continue;// should not happenvarimg=document.createElement("img");img.src=info.thumburl;img.width=info.thumbwidth;img.height=info.thumbheight;img.alt=title;varlink=document.createElement("a");link.href=info.descriptionurl;link.title=title;link.className='ifd-thumbnail';link.appendChild(img);heading.parentNode.insertBefore(link,heading.nextSibling);}};varqueryPrefix=mw.config.get('wgServer')+mw.config.get('wgScriptPath')+"/api.php?format=json&action=query&maxage=3600&prop=imageinfo&iiprop=url&iiurlwidth=80&iiurlheight=80&titles=";varbatchSize=50;for(vari=0;i<images.length;i+=batchSize)$.getJSON(queryPrefix+encodeURIComponent(images.slice(i,i+batchSize).join("|"))).then(showThumbnails);};$(createThumbnails);}