Jump to content

MediaWiki talk:Gadget-ImageAnnotator.js

Add topic
From Wikimedia Commons, the free media repository
Latest comment: 1 day ago by Nux in topic Disable on mobile (non-hover devices)
MediaWiki:Gadget-ImageAnnotator.js forms part of the MediaWiki interface and can only be edited by administrators, stewards and interface editors.
To request a change to MediaWiki:Gadget-ImageAnnotator.js, add {{Edit request}} to this talk page, followed by a description of your request.
This gadget is enabled globally for everyone through an inclusion in MediaWiki:Common.js. You need not (and in fact, cannot) enable it in any way; it is already enabled. In case of an insurmountable problem, there's an emergency switch-off that logged-in users can use: just enable at Special:Preferences→Gadgets the gadget for "disabling image annotations". If you feel the need to do that, please also report your problem here.

To see all annotated images, visit Category:Images with annotations.
Documentation on this script is at Help:Gadget-ImageAnnotator.

Archives
Conversations older than 7 days will be archived automatically.
Pending tasks for Gadget-ImageAnnotator.js: edit this list - add to watchlist - purge
None of these need to be fixed immediately, but they should be looked at eventually.
  • Provide a way to edit rectangles (allow size changes).
  • Icons instead of rectangles for some notes? (See here and here.)
  • Grouping of notes into layers? (See here.)
ImageAnnotator's Documentation.
ImageAnnotator's Frequently Asked Questions.
ImageAnnotator's technical Forum.
ImageAnnotator's non-technical Forum.
Image note guideline.

Not showing when browsing zoomed in

[edit]

I usually browse at 133% zoom. Both annotations and the "add notes" button dont show up. RoyZuo (talk) 06:10, 26 March 2025 (UTC)Reply

the problem seems to occur only when the image would go beyond the width. so for example File:" 12 - ITALY - Gun Collection FLOS 3.JPG is still within the width of the page annotations can be shown. RoyZuo (talk) 06:53, 26 March 2025 (UTC)Reply
It looks like it's failing the img_check() when the image is scaled because of https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+blame/f172d591dfd6180b0a552fc2e3c50dd5e6770ad3/resources/src/mediawiki.action/mediawiki.action.view.filepage.less#196 . I'm not sure why that's breaking *now* and not 2 years ago when that change was made though. I'm not sure what the best way to fix it is either; the #file img {max-width: unset !important;} I threw in my common.css to test probably isn't it, but I don't exactly trust ImageAnnotator enough to remove the exact size check. TheDJ, any thoughts? AntiCompositeNumber (talk) 21:03, 1 May 2025 (UTC)Reply
It seems to make some assumptions about having space available and images not ever being scaled. That seems a somewhat strict assumption, that should probably be modified. I'll see if I can modify the gadget.
// Quit if the image wasn't loaded properly for some reason:
if ( w != srcW || Math.abs( srcH - h ) > 1 ) { // `h != srcH` but allowing for off-by-one error / rounding (works around T370300)
	return null;
}
TheDJ (talkcontribs) 08:57, 6 June 2025 (UTC)Reply

No inline/thumb annotations now?

[edit]

Example in Help:Image-Annotator#Inline_display_of_annotations is not working for me on:

  • Firefox Dev 140.0 (Windows 11), logged in AND in private mode
  • Edge 137.0.3296.62 (Windows 11), not logged in

Clicking through to the file page works. What is going on? Artoria2e5 contribs 09:55, 6 June 2025 (UTC)Reply

Issue still persists as of 7 August 2026 unfortunately. I'm using Firefox 152.0.6 and I'm logged in. ForeverFlying (talk) 02:17, 8 August 2026 (UTC)Reply

annotations with problems

[edit]

Possibly related to phab:T332644.

since yesterday in the evening (or earlier?) the "Add"-Button and all annotations are no longer visible, LudwigSebastianMicheler (talk) 09:56, 1 September 2026 (UTC)Reply

The same for me.
I can't see the "Add" button but also I can't see notes on images that have them.
I'm using Chrome on Windows. Pere prlpz (talk) 11:03, 2 September 2026 (UTC)Reply
Same here with Firefox 155 on Windows 11. Raymond (talk) 11:24, 2 September 2026 (UTC)Reply
+1 --Milseburg (talk) 13:46, 2 September 2026 (UTC)Reply
Same on Linux, Firefox Bojan Marušič (talk) 15:01, 2 September 2026 (UTC)Reply
Same on Linux TUXEDO OS 24.04.4 LTS, Firefox 154.0.1. Please fix it, i urgently need it. --Arnd 🇺🇦 (talk) 18:27, 2 September 2026 (UTC)Reply
As reported above, it doesn't show on Firefox 154.0.1 either. --Nenea hartia (talk) 08:25, 3 September 2026 (UTC)Reply
Same on Firefox and Edge. Nicolas4000 (talk) 08:47, 3 September 2026 (UTC)Reply
Same on Safari 26.5.2 on macOS Tahoe 26.5.2, Trying to change image size (Appearance) did not solve the problem Yair-haklai (talk) 09:10, 3 September 2026 (UTC)Reply
Hello. Same issue. Sebring12Hrs (talk) 17:54, 3 September 2026 (UTC)Reply

Is there a phabricator ticket on this? - Jmabel ! talk 20:40, 3 September 2026 (UTC)Reply

Gadgets are rarely tracked on Phabricator, but in this case, based on the timing, I think there is a relevant task: phab:T332644. (I tried to track down how the gadget tries to add the Add button, but I got lost in this ancient pre-jQuery stuff that tries to implement everything on its own… So it’s just a guess that T332644 may be the cause.) —Tacsipacsi (talk) 06:38, 4 September 2026 (UTC)Reply
Thanks, I've added a note to phab:T332644. - Jmabel ! talk 19:43, 4 September 2026 (UTC)Reply

Seems to work again. --Herzi Pinki (talk) 20:56, 4 September 2026 (UTC)Reply

It doesn't work for me, with two browsers and two accounts. I still can't see the add note button and the "Open Media Viewer" button shows in the wrong place, as others explained. Pere prlpz (talk) 21:03, 4 September 2026 (UTC)Reply

works in rare cases e.g. File:Kreuzspitze-Grossvenediger.jpg --Herzi Pinki (talk) 21:02, 4 September 2026 (UTC)Reply

Yes, this one also works for me. I wonder why. Pere prlpz (talk) 21:04, 4 September 2026 (UTC)Reply
I found more (e.g. File:"Ansicht des Narrenthurms, dan des Universal- und Militaire-Spitals, von der Rückseite" (Jos. Schaffer, 1787).jpg), all below a size of around 150 kByte. I suspect size matters. --Herzi Pinki (talk) 21:17, 4 September 2026 (UTC)Reply
It's not the size in bytes, but the number of pixels in both dimensions. Below 1.000 × 1.000 it seems to work (e.g. File:'Leaves from a Hunting Diary in Essex' p.114 - Matching Green 01.jpg), 1.024 does not work. --Herzi Pinki (talk) 21:25, 4 September 2026 (UTC)Reply
Agreed that it seems to work for small images, although not for all images under 1000x1000 px. Pere prlpz (talk) 21:36, 4 September 2026 (UTC)Reply
It seems to work for some very small images Yair-haklai (talk) 06:19, 5 September 2026 (UTC)Reply
@Pere prlpz: maybe an example might be useful (an image < 1000x1000 px, where it does not work). best --Herzi Pinki (talk) 12:26, 5 September 2026 (UTC)Reply
I'd need to find it again, but it was over 900px in one direction. For the very small images I checked it worked. Pere prlpz (talk) 12:29, 5 September 2026 (UTC)Reply
not really important. The 1000 was a guess, the 1024 px a likely limit. It could be any other magic number lower than 1000. I just wanted to provide a lever, where to start fixing the problem (I have no idea how and where to fix it, but as the problem is depending on some size limits it's likely caused by some function called by the annotator and not by the embedding environment). --Herzi Pinki (talk) 16:45, 5 September 2026 (UTC)Reply
mini photo with annotations (cropped today)--LudwigSebastianMicheler (talk) 00:08, 6 September 2026 (UTC)Reply

okay, the immage annotator is not destroyed, only damaged, for mini photos it works,--LudwigSebastianMicheler (talk) 00:08, 6 September 2026 (UTC)Reply

I have to increase the appearance from 640 x 480 to
800 x 600 or to 1024 x 786 in order to let the annotator to work on this mini photo. Yair-haklai (talk) 06:12, 6 September 2026 (UTC)Reply
I found and fixed one issue, which was a regex for the thumbnail URL that didn't include the new thumb.wikimedia.org (phab:T427465). If there are other pages that are still not working, please include a link. --AntiCompositeNumber (they/them) (talk) 19:24, 6 September 2026 (UTC)Reply
Great Yair-haklai (talk) 21:25, 6 September 2026 (UTC)Reply
It works fine for me, now. Thank you. Pere prlpz (talk) 21:26, 6 September 2026 (UTC)Reply
@AntiCompositeNumber doesn't seem to be working with images on thumb domain, e.g. File:Berliner kongress.jpg (so big images). I don't see any yellow rectangles. Nux (talk··dyskusja) 21:51, 6 September 2026 (UTC)Reply
You have to update your Appearance (Image size limit on file description pages) Yair-haklai (talk) 21:55, 6 September 2026 (UTC)Reply
I have 1024x768px which is one of standard options. Nux (talk··dyskusja) 22:10, 6 September 2026 (UTC)Reply
@Nux, It works fine for me at 1024x768px, please w:WP:BYPASS your cache and make sure you're running the current version of the scripts. AntiCompositeNumber (they/them) (talk) 22:20, 6 September 2026 (UTC)Reply
The problem seem to be in function img_check( img, is_other ) {
Vector uses dynamic image size:
#file img { max-width: 100%; height: auto; }
So this can be different all the time.
var srcW = parseInt( img.getAttribute( 'width', 2 ), 10 ); var w = img.clientWidth;
if ( w != srcW ... )
Not sure why annotator even checks it. It could just ignore client size and force width from attr (which will make the image go out of frame). Or keep client size. Nux (talk··dyskusja) 22:25, 6 September 2026 (UTC)Reply

Disable on mobile (non-hover devices)

[edit]

I noticed this probably never worked on mobile (because of how `img_check` works checking size whihc is not constant on mobile). We should probably disable `ImageAnnotator` on mobile (devices without hover). It's quite a lot of code on its own, plus even more from the four dependencies it loads. Nux (talk··dyskusja) 22:33, 6 September 2026 (UTC)Reply