From 192aba1c301153b962db38dca4c60a41ddabcdb0 Mon Sep 17 00:00:00 2001 From: Marwin Hochfelsner <50826859+hlfan@users.noreply.github.com> Date: Fri, 18 Jul 2025 01:40:17 +0200 Subject: [PATCH] Force desktop endpoints for Commons image redirects Always requesting the desktop "view" by appending `?mobileaction=toggle_view_desktop` to redirect URLs removes the network hop over commons.m.wikimedia.org and simplifies the CSP requirements for mobile clients. This `img.src` modification does not affect subsequent user-initiated navigation on Commons, nor does it trigger any layout change. --- app/assets/javascripts/index/element.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/index/element.js b/app/assets/javascripts/index/element.js index 9561a8b14..8d2995a24 100644 --- a/app/assets/javascripts/index/element.js +++ b/app/assets/javascripts/index/element.js @@ -171,8 +171,8 @@ .addClass("bg-body-tertiary"); if (icon && OSM.WIKIMEDIA_COMMONS_URL) { - let src = OSM.WIKIMEDIA_COMMONS_URL + "Special:Redirect/file/" + encodeURIComponent(icon); - if (!icon.endsWith(".svg")) src += "?width=128"; + let src = OSM.WIKIMEDIA_COMMONS_URL + "Special:Redirect/file/" + encodeURIComponent(icon) + "?mobileaction=toggle_view_desktop"; + if (!icon.endsWith(".svg")) src += "&width=128"; $("") .attr("href", OSM.WIKIMEDIA_COMMONS_URL + "File:" + encodeURIComponent(icon) + `?uselang=${OSM.i18n.locale}`) .append($("").attr({ src, height: "32" })) -- 2.39.5