Widget:HouseTile

Aus Herrenhäuser
Version vom 22. Oktober 2024, 11:40 Uhr von Admin (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „var params = { action: 'query', prop: 'images', titles: 'Christinehof', // Replace this with the desired page title format: 'json' }, api = new mw.Api(); api.get(params).done(function (data) { var pages = data.query.pages, page, firstImage; for (page in pages) { // Check if the page has images if (pages[page].images && pages[page].images.length > 0) { firstImage = pages[page].images[0]; // Ge…“)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Wechseln zu: Navigation, Suche

var params = {

   action: 'query',
   prop: 'images',
   titles: 'Christinehof',  // Replace this with the desired page title
   format: 'json'

}, api = new mw.Api();

api.get(params).done(function (data) {

   var pages = data.query.pages,
       page, firstImage;
   for (page in pages) {
       // Check if the page has images
       if (pages[page].images && pages[page].images.length > 0) {
           firstImage = pages[page].images[0];  // Get the first image
           console.log(firstImage.title);  // Output the title of the first image
           break;  // Stop after finding the first image
       } else {
           console.log('No images found.');
       }
   }

});