MediaWiki talk:Gadget-Stockphoto.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
MediaWiki:Gadget-Stockphoto.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-Stockphoto.js, add {{Edit request}} to this talk page, followed by a description of your request.
This interface message or skin may be documented on mediawiki.org or translatewiki.net.
When editing this script please adhere to the Commons:JavaScript styleguide.
SpBot archives all sections tagged with {{Section resolved|1=~~~~}} after 3 days.

Stockphoto gadget on Commons URL-encodes HTML entities in "Use this file on the web"[edit]

{{Edit request}}

List of steps to reproduce (step by step, including full links if applicable):

   visit https://commons.wikimedia.org/wiki/File:Cornus_sericea_1208027.jpg
   click on "Use this file on the web"
   copy content of "Embed this file"

What happens?: This is the code suggested to embed:

<a title="Dave Powell, USDA Forest Service, Bugwood.org, CC BY 3.0 <https://creativecommons.org/licenses/by/3.0>, via Wikimedia Commons" href="https://commons.wikimedia.org/wiki/File:Cornus_sericea_1208027.jpg"><img width="256" alt="Cornus sericea 1208027" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/f4/Cornus_sericea_1208027.jpg/256px-Cornus_sericea_1208027.jpg"></a>

What should have happened instead?: In the opening <a>-tag you find this piece of code:

<https://creativecommons.org/licenses/by/3.0>

The entities for < and > arround the URL produce < and > when embedding for instance in a wordpress page and prevents the code to work, the image does not appear.

Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc: the current version of Wikimedia Commons.

--Christian Ries (talk) 14:58, 23 August 2021 (UTC)[reply]


Hi @cries, thanks for taking the time to report this! This is a local gadget on Wikimedia Commons.

User scripts, gadgets, templates, custom CSS are local on-wiki content. Local content is managed independently on each wiki, by each wiki community themselves. Phabricator is mostly used for MediaWiki, MediaWiki extensions, or server configuration, or by developers and teams to organize what they plan to work on. This needs fixing on the local wiki, likely in https://commons.wikimedia.org/wiki/MediaWiki:Gadget-Stockphoto.js . Please bring this up on the local wiki. Hence I am closing this task here - thanks for your understanding!

TASK DETAIL https://phabricator.wikimedia.org/T289494

EMAIL PREFERENCES https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Aklapper Cc: Aklapper, cries, DannyS712, Analytics.mediafiles, Jayprakash12345

@Christian Ries: I can’t reproduce this anymore; I now get:
<a title="Dave Powell, USDA Forest Service, Bugwood.org, CC BY 3.0 &lt;https://creativecommons.org/licenses/by/3.0&gt;, via Wikimedia Commons" href="https://commons.wikimedia.org/wiki/File:Cornus_sericea_1208027.jpg"><img width="256" alt="Cornus sericea 1208027" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/f4/Cornus_sericea_1208027.jpg/256px-Cornus_sericea_1208027.jpg"></a>
– note that it now uses &lt; and &gt; correctly. --Lucas Werkmeister (talk) 19:09, 30 September 2023 (UTC)[reply]

"Use this file on the web" iframe embed code for Common videos do not provide correct width and height values[edit]

As it says in the headline. :) It looks like the width and height values are not being passed to the generated HTML iframe code. Ckoerner (talk) 19:50, 13 September 2022 (UTC)[reply]

Fixed if someone deploys #Some_updates. —TheDJ (talkcontribs) 14:22, 21 April 2024 (UTC)[reply]

"embed_this_file" ("undefined")[edit]

Note that most languages instead of showing the field "Embed this file" show "undefined" (and since many years) because they do not have the entry "embed_this_file" defined. This is true at least for French, German and Italian. Please see MediaWiki talk:Gadget-Stockphoto.js/it and related languages. --Valerio Bozzolan (talk) 14:02, 6 October 2022 (UTC)[reply]

Correct display of two licenses[edit]

The File:Android update.jpg file has two licenses. One in the photo and the other on android. And the problem is that when you click on "Use this file" only one is shown Артём 13327 (talk) 18:52, 29 October 2022 (UTC)[reply]

About internationalization of Chinese[edit]

This gadget has localization of zh. However, in many cases, our interface language is not zh, but its variants, such as zh-sg and zh-tw. There should be some additional handling of internationalization for this language, so as to use zh when my interface language is any variant of Chinese.

Besides, considering MediaWiki:Gadget-Stockphoto.js/zh is written in simplified Chinese, a traditional Chinese version (which can be named MediaWiki:Gadget-Stockphoto.js/zh-hant) is needed, for zh-hant/tw/hk/mo ot be used. SolidBlock (talk) 11:13, 15 July 2023 (UTC)[reply]

Edit request[edit]

{{Edit request}} Hello, I wish change the icons of MediaWiki:Gadget-Stockphoto.js by replacing the icons by : File:OOjs UI icon download.svg (), File:OOjs UI icon arrowNext-ltr.svg (), File:OOjs UI icon logo-wikipedia.svg (), File:OOjs UI icon message.svg (), File:OOjs UI icon lightbulb.svg () and File:OOjs UI icon close-ltr.svg (). What do you think ? Cordially <span data-dtsignatureforswitching="1"></span> manȷıro💬 18:44, 30 July 2023 (UTC)[reply]

@Manjiro5: IMHO this should be discussed somewhere else first, maybe COM:VP; I don’t want to change it based on just one user suggesting it, and it doesn’t seem to have generated any discussion here so far. --Lucas Werkmeister (talk) 19:11, 30 September 2023 (UTC)[reply]
@Lucas Werkmeister Hello, firstly, thanks for your answer ;-) . I will do the proposal tomorrow in the village pump. Have a nice day/night. Regards, manȷıro💬 21:32, 30 September 2023 (UTC)[reply]

Default markup for 'Use this image' is suboptimal[edit]

For an image - say: File:Aris’s Birmingham Gazette - 1771-11-11 - p1.jpg - the default markup provided by the "Use this file" link on the toolbar is:

[[File:Aris’s Birmingham Gazette - 1771-11-11 - p1.jpg|thumb|Aris’s Birmingham Gazette - 1771-11-11 - p1]]

The right hand part of this ("|Aris’s Birmingham Gazette - 1771-11-11 - p1]]") repeats the filename. It should instead (where available) use the caption from the file's structured data, in the user's preferred language:

[[File:Aris’s Birmingham Gazette - 1771-11-11 - p1.jpg|thumb|front page masthead of Aris’s Birmingham Gazette, 11 November 1771 edition]]

This applies to all the applicable markup snippets under each of the "Use this file" links on a file page; for example the non-thumbnail wiki markup and the alt attribute under "Embed this file".

I'm told This probably would require changes in MediaWiki:Gadget-Stockphoto.js

I'm hopeful we might get someone to look at this during the Wikimedia hackathon, in progress as I write. Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 03:28, 15 August 2023 (UTC)[reply]

There were no takers at Wikimania, so this still needs attention Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 18:31, 25 August 2023 (UTC)[reply]
@Pigsonthewing: I'm not really a JavaScript programmer, but with a bit of thrashing around I seem to have something in User:bjh21/Gadget-Stockphoto.js that does what you asked for. The change is in the code that sets up file.title around lines 60-65. --bjh21 (talk) 18:55, 22 February 2024 (UTC)[reply]
Thank you. How do we get this applied? Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 21:33, 22 February 2024 (UTC)[reply]
@Pigsonthewing: I think (1) be confident that the change has consensus or is uncontroversial, and (2) add {{Edit request|technical}} here which will add the page to Category:Commons protected edit requests for interface administrators. --bjh21 (talk) 16:19, 25 February 2024 (UTC)[reply]
Thank you.
Regarding 1), does anyone have an objection, or a counter-proposal? Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 18:43, 25 February 2024 (UTC)[reply]
For the record, I  support this change. It's not perfect, but it's better than what we currently have. --bjh21 (talk) 16:02, 28 February 2024 (UTC)[reply]
I just posted a similar request down at the bottom of the page, so I support this. I was directed here at the most recent NYC hackathon even FYI. I feel like at some point it did actually work this way, but maybe I'm Mandela-ing. Tduk (talk) 17:35, 18 March 2024 (UTC)[reply]
It is requested that an edit or modification be made to this protected page.
Administrators: Please apply <nowiki> or {{Tl}} to the tag after the request is fulfilled.

Lucas Werkmeister

I support this too and don't think there's anything controversial about it. Tested the posted code and it looks good to me, I just made some minor formatting and comment edits below. For clarity this should replace lines 60–62.

  // Try the SDC caption first. This might usefully be enhanced to try
  // languages other than the user's preferred one.
  var caption = mw.config.get('wbEntity').labels[mw.config.get('wgUserLanguage')];
  if (caption != undefined) {
    file.title = caption.value;
  } else {
    // Fall back to file name
    // Strip namespace prefix and file suffix, use spaces for underscore.
    file.title = opt.pageName.replace(/^[^:]+:|\.[^.]+$/g, '').replace(/_+/g, ' ');
  }

-- the wub "?!" 00:42, 30 March 2024 (UTC)[reply]

Adding a link "Gadget info"[edit]

It would be awesome to put a link "Gadget info" in the footer of the popup to reach the page MediaWiki:Gadget-Stockphoto.js and find more info. This would allow some users to meet the documentation, join discussions, report problems in the translations, eventually become a developer, etc., hoping to report and fix problems more efficiently. bozz (talk) 11:25, 4 September 2023 (UTC)[reply]

Good idea, but I’d rather link to Help:Gadget-Stockphoto as that’s more useful for the average (non-techy) user (and Help:Gadget-Stockphoto can link to the source code), and would place the link in the icon list appearing next to the image rather than in a modal window for discoverability. —Tacsipacsi (talk) 00:37, 5 September 2023 (UTC)[reply]

Gadget-Stockphoto.js causes unwanted scrolling behavior on File: pages[edit]

As discussed in this Phabricator issue, when enabled, this gadget has been pinpointed as the source of a bug that causes File: pages to scroll upwards by themselves after a page refresh while the page is scrolled down part of the way.

Screen recording of the bug in action: https://archive.org/download/c9sm3/bug.webm
OS: Linux Mint 20.2; Browser: Firefox 117.0.1 (64-bit)
All addons/userscripts/custom css/templates/other gadgets were disabled during pinpointing the cause of the bug. –Vuccala (talk) 14:03, 27 September 2023 (UTC)[reply]

"Use this file on wiki" supplies the file name as the description[edit]

I seem to remember that some time ago, that "use this file" would use the description from the wiki page/metadata if available, for populating the thumbnail/image use code, so that it would appear under the image when placed in an article. At some point, it seems to have switched to supplying the filename both as the filename field and the description field, which is in most cases counter-productive even if it's the original intent, unless I'm missing something. Tduk (talk) 15:27, 17 March 2024 (UTC)[reply]

I see this was already asked for up above..! Tduk (talk) 17:35, 18 March 2024 (UTC)[reply]

Some updates[edit]

{{Editrequested}} I have a version here User:TheDJ/stockphoto.js which solves several problems

  • Download links not actually triggering a download
  • Broken audio and video integration
  • Several unrecognized audio/video formats that are supported these days
  • Updates for iframe of video
  • non-Retina resolution of close button

These were some annoyances I've been having for a while, and while i think this gadget needs full on replacement, this at least avoids people running into broken stuff a bit. —TheDJ (talkcontribs) 14:11, 21 April 2024 (UTC)[reply]

✓ Done (TIL we can use ... in JS code now!) --Lucas Werkmeister (talk) 07:00, 5 May 2024 (UTC)[reply]