MediaWiki:CRT Search.js: Difference between revisions

 
No edit summary
Line 1,141: Line 1,141:
         var img = printout[0];
         var img = printout[0];
          
          
         if (typeof img === 'object' && img.fullurl) {
        // Extract filename from various formats SMW might return
             return img.fullurl;
        var imgName;
         if (typeof img === 'object') {
            // SMW returns object with fulltext like "File:filename.jpg"
            imgName = img.fulltext || '';
        } else {
             imgName = String(img);
         }
         }
          
          
         // Construct URL from filename
         // Remove "File:" prefix if present
         var imgName = String(img).replace(/^File:/, '');
         imgName = imgName.replace(/^File:/, '');
         return mw.config.get('wgScriptPath') + '/index.php?title=Special:Redirect/file/' +  
          
              encodeURIComponent(imgName) + '&width=160';
        if (!imgName) return null;
       
        // Use Special:Redirect/file to get the actual image with thumbnail
        return '/wiki/Special:Redirect/file/' + encodeURIComponent(imgName) + '?width=160';
     }
     }


MediaWiki Appliance - Powered by TurnKey Linux