For logged-out users, Commons uses a script called AnonymousI18N.js instead of the Universal Language Selector to provide language-switching functionality (logged-in users get ULS).
When this script is active, it breaks the QuickView functionality on our experimental Special:MediaSearch page by injecting its own behavior (which is to navigate the user to the target page with the appropriate language params added to the URL):
// Prevent the default linking functionalty and instead use getUrlForLanguage() e.preventDefault(); location.href = AnonymousI18N.getUrlForLanguage(href_full, wgAnonUserLanguage);
We want links in the MediaSearch results grid to have a different behavior. Rather than immediately taking the user to a new page, we want them to open a "quickview" sidebar which shows a preview of the given media file in-place. But we still want to use link elements here so that the user can control-click to open a result in a new tab, etc.
Since this is an on-wiki script, I've added a proposal on the relevant talk page to add support for disabling on specific pages (maybe through a JS config var or similar): https://commons.wikimedia.org/wiki/MediaWiki_talk:AnonymousI18N.js#Allow_specific_pages_to_disable_this_script
Steps to Reproduce:
Perform a media search in a non-English language as an anonymous user, for example:
https://commons.wikimedia.org/wiki/Special:MediaSearch?type=bitmap&quickview=true&q=cat&debug=true&uselang=de
Make sure to let the page JS fully load; this can take extra time with debug mode on, and click an image result.
Actual Results:
The user is taken directly to the File page of the clicked result.
Expected Results:
The QuickView element should appear on the right-hand side of the same page. Compare with what happens when you search in the default language:
https://commons.wikimedia.org/wiki/Special:MediaSearch?type=bitmap&quickview=true&q=cat&debug=true
QA Notes
This patch will be live on Production commons next Wednesday (August 19), assuming the train goes out as it normally would. At that point, we should be able to test if users of the AnonymousI18N.js language switcher are able to see the Quickview normally (quickview=true params will still need to be present in the URL of course).
Instructions for testing (once patch is live):
- Navigate to Special:MediaSearch page (with quickview=true url params: https://commons.wikimedia.org/wiki/Special:MediaSearch?quickview=true
- Ensure you are logged out
- Make a search and click on an Image, Audio, or Video result (category results do not have QuickView enabled); the Quickview panel should appear
- Try switching the language by 1) using the drop-down menu in the sidebar, or 2) adding the uselang=whatever params directly to the URL
- Try clicking on a search result after the language has been changed; QuickView should still appear