Maak jij deze zomer 2025 Het Perfecte WikiKids-kiekje? Iedereen kan meedoen!
Gebruiker:Southparkfan/GoogleImages.js: verschil tussen versies
Naar navigatie springen
Naar zoeken springen
k (Southparkfan heeft de pagina Gebruiker:JurgenNL/GoogleImages.js hernoemd naar Gebruiker:Southparkfan/GoogleImages.js zonder een doorverwijzing achter te laten) |
(niet moeilijk doen) |
||
(Een tussenliggende versie door dezelfde gebruiker niet weergegeven) | |||
Regel 1: | Regel 1: | ||
− | + | ||
// bron: https://commons.wikimedia.org/wiki/MediaWiki:Gadget-GoogleImages.js (CC-BY-SA 3.0) | // bron: https://commons.wikimedia.org/wiki/MediaWiki:Gadget-GoogleImages.js (CC-BY-SA 3.0) | ||
/*global mw, jQuery*/ | /*global mw, jQuery*/ | ||
Regel 16: | Regel 16: | ||
if (document.getElementById('file').getElementsByTagName('img').length <= 0) return; | if (document.getElementById('file').getElementsByTagName('img').length <= 0) return; | ||
− | + | imageurl = document.getElementById('file').getElementsByTagName('img')[0].src; | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
mw.util.addPortletLink('p-cactions', 'https://www.google.com/searchbyimage?image_url=' + encodeURIComponent(imageurl), 'Google Images', 'ca-googleimages', null); | mw.util.addPortletLink('p-cactions', 'https://www.google.com/searchbyimage?image_url=' + encodeURIComponent(imageurl), 'Google Images', 'ca-googleimages', null); | ||
}); | }); |
Huidige versie van 15 mei 2016 om 15:04
// bron: https://commons.wikimedia.org/wiki/MediaWiki:Gadget-GoogleImages.js (CC-BY-SA 3.0)
/*global mw, jQuery*/
/*jshint curly:false */
jQuery(document).ready(function() {
'use strict';
if (mw.config.get('wgNamespaceNumber') !== 6 || mw.config.get('wgAction') !== "view" || !document.getElementById('file')) return;
var imgs = document.getElementById('file').getElementsByTagName('img');
if (!imgs || imgs.length === 0) return; // No preview image, e.g. for large PNGs
var imageurl = imgs[0].parentNode.href;
if (!imageurl) return; /* This occurs with thumbs of videos for instance */
// For the case of 'Error creating thumbnail: Invalid thumbnail parameters or PNG file with more than 12.5 million pixels'
if (document.getElementById('file').getElementsByTagName('img').length <= 0) return;
imageurl = document.getElementById('file').getElementsByTagName('img')[0].src;
mw.util.addPortletLink('p-cactions', 'https://www.google.com/searchbyimage?image_url=' + encodeURIComponent(imageurl), 'Google Images', 'ca-googleimages', null);
});