MediaWiki:CRT Search.js: Difference between revisions
Created page with "→* * EveryCRT Advanced Search * Server-side faceted search using Semantic MediaWiki API * * Installation: * 1. Create MediaWiki:AdvancedSearch.js with this content * 2. Create MediaWiki:AdvancedSearch.css with the companion stylesheet * 3. Add to MediaWiki:Common.js: * if (mw.config.get('wgPageName') === 'Advanced_Search') { * mw.loader.load('/wiki/MediaWiki:AdvancedSearch.js?action=raw&ctype=text/javascript'); * }: (function() { 'use stri..." |
No edit summary |
||
| Line 1,141: | Line 1,141: | ||
var img = printout[0]; | var img = printout[0]; | ||
if (typeof img === 'object' | // Extract filename from various formats SMW might return | ||
var imgName; | |||
if (typeof img === 'object') { | |||
// SMW returns object with fulltext like "File:filename.jpg" | |||
imgName = img.fulltext || ''; | |||
} else { | |||
imgName = String(img); | |||
} | } | ||
// | // Remove "File:" prefix if present | ||
imgName = imgName.replace(/^File:/, ''); | |||
return | |||
if (!imgName) return null; | |||
// Use Special:Redirect/file to get the actual image with thumbnail | |||
return '/wiki/Special:Redirect/file/' + encodeURIComponent(imgName) + '?width=160'; | |||
} | } | ||