MediaWiki:Gadget-ImageAnnotator.js: Difference between revisions

Content deleted Content added
V2.3a
m TIFF support, and fix checking for thumb img URLs: last component (thumb filename) may differ depending on image scaler used; hence look at real page name (thumb directory)
Line 2:
 
/*
THIS IS ImageAnnotator VERSION 2.3a3b
 
Image annotations. Draw rectangles onto image thumbnail displayed on image description
Line 1,744:
if (scope == document) {
img = LAPI.WP.getPreviewImage (wgTitle);
// TIFFs may be multi-paged: allow only for single-page TIFFs
if ( document.pageselector ) img = null;
} else if (is_other) {
img = scope;
Line 1,768 ⟶ 1,770:
name = name.replace (/ /g, '_');
if (is_thumb || is_other) {
var img_src = decodeURIComponent (img.getAttribute ('src', 2)).replace (/ /g, '_');
// img_src =should decodeURIComponenthave (img_src.substringa (img_src.lastIndexOfcomponent ('"/')name" in +there 1))somewhere
.replace (/ /g, '_')
.replace (/(\.svg)\.png$/i, '$1')
;
var colon = name.indexOf (':');
if (colon <= 0) return null;
var img_name = name.substring (colon + 1);
if (img_src.search(new RegExp('/' + img_name.escapeRE() !=+ img_src'(/.*)?$')) < 0)
&& !(img_src.endsWith (img_name)
&& /^\d+px-$/.test (img_src.substring (0, img_src.length - img_name.length))
)
)
return null;
// If the link is not going to file namespace, we won't find the full size later on and
Line 1,786 ⟶ 1,781:
}
}
if (name.search (/\.(jpe?g|png|gif|svg|tiff?)$/i) < 0) return null; // Only PNG, JPE?G, GIF, SVG, and TIFF?
// Finally check for wpImageAnnotatorControl
var icon_only = false;