Module talk:Random slideshow/Archive 1

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
Archive 1

Portraits and panoramas

 – Evad37 [talk] 05:34, 23 August 2018 (UTC)

Hi, would it be possible to add a height parameter in addition to width, so that you can limit the size of portrait-format images? And, ideally, would it be also possible to add a functionality similar to Wide image to better display panoramic pictures? — Kpalion(talk) 16:00, 19 July 2018 (UTC)

Ideally some way of limiting the image size to fit into the screen. · · · Peter (Southwood) (talk): 17:26, 28 July 2018 (UTC)

Non-free images being included in slideshows

 – Evad37 [talk] 05:34, 23 August 2018 (UTC)

Is there a way to tweak this templates syntax so that it doesn't call up any non-free images when it's used on pages like Portal:Anti-nuclear movement? Non-free files are only allowed to be used in the article namespace per WP:NFCC#9 which means they shouldn't be displayed on portal pages. -- Marchjuly (talk) 04:15, 23 August 2018 (UTC)

@Marchjuly: This should already be done... Module:Excerpt is used to parse page content, which tests images and excludes those which are non-free. Which specific image or images are slipping through? - Evad37 [talk] 04:50, 23 August 2018 (UTC)
File:Nuclear hand.png is getting flagged as being used on "Portal:Anti-nuclear movement". -- Marchjuly (talk) 04:55, 23 August 2018 (UTC)
So its a non-free file within a gallery, which probably shouldn't be there in the first case per Wikipedia:Non-free_content#Multimedia. But in any case, I'm modifying the code to also check gallery files (which are processed separately to other files) for non-free content. - Evad37 [talk] 05:12, 23 August 2018 (UTC)
 Done - Evad37 [talk] 05:17, 23 August 2018 (UTC)
Thanks Evad37. -- Marchjuly (talk) 05:25, 23 August 2018 (UTC)
@Evad37: Would you mind taking a look at Portal:Tron. The same thing that happened above seems to be happening in that portal regarding File:Tron2lightcycle.jpg and File:Tron Lightcycles.jpg. -- Marchjuly (talk) 05:36, 27 August 2018 (UTC)
@Marchjuly:  Fixed. They were specified on the portal itself, so just needs to be removed there [1] - Evad37 [talk] 05:55, 27 August 2018 (UTC)
Thank you. -- Marchjuly (talk) 06:10, 27 August 2018 (UTC)

HTML code appearing in the captions of some images

Several images use templates in their captions, such as for keys in maps (see Territories of the United States) and it would be a good idea to either:

  • Remove the result of the templates (so remove HTML code from captions)
  • Allow the template to show its content/results (so allow parsing of HTML code in the image captions)

See Portal:United States Territories for an example of this happening, but I have seen it in other portals. Dreamy Jazz 🎷 talk to me | my contributions 17:07, 11 September 2018 (UTC)

 Fixed, just needed to make sure linebreaks were removed from expanded templates - Evad37 [talk] 02:29, 12 September 2018 (UTC)

Image dimensions displayed as captions

As used at Portal:Greek alphabet, the code

{{Transclude files as random slideshow
| Greek alphabet
|
|
}}

produces captions like x12px for many of the images. To me, these are image dimensions, not intended to be shown to the non-editing reader. --Redrose64 🌹 (talk) 23:16, 27 February 2019 (UTC)

@Redrose64:  Fixed. The module was previously sometimes confusing the size for the caption; now it will either display the real caption, or leave off the caption if there isn't one. - Evad37 [talk] 00:24, 28 February 2019 (UTC)
Thank you --Redrose64 🌹 (talk) 10:54, 28 February 2019 (UTC)

Nifty use of this template for a sidebar slideshow, maybe we should support this correctly?

{{Sidebar
| pretitle = Some effects of climate change
| pretitlestyle = font-weight:bold;
| cellspacing = 0
| cellpadding = 0
| width =
| style = border:1px solid #c8ccd1;
| content1style = margin:-5px -5px -2.2em -5px; display: inline-block;
| content1 = {{Transclude files as random slideshow
| Global warming | section1= Nature and wildlife
| Global warming | section2= Humans}}
| content2style = height:0px; margin:0 -0.4em; padding:0; display:inline-block; visibility:hidden; 
| content2 = [[File:Sea_level_history_and_projections.svg|frameless|border|upright=1.35]]
}}

I used the "Transclude files as random slideshow" template to create a sidebar slideshow. While the markup is pretty minimal, there are several semi-hacks I had to do to get it to work:

  1. I wrapped the "Transclude files as random slideshow" template in the "sidebar" template
  2. The edge spacing on the gallery is too much for fitting in the side bar, so to zoom it in I used negative margins with inline-block display
  3. You can't size the gallery according to a thumbnail, so to get the sizing right I include a hidden image in the sidebar and then size the gallery to that
  4. The trouble then is that if you click another image in the page and then use the right / left directional arrows to go through all images, you'll see the hidden image. To work around THAT, I stuffed in a fallback image in the hidden location.
  5. Tweaked the border color to match thumbnail pics

The images only appear on desktop for some reason; on mobile all images are hidden, even though the template documentation says that 4 images should be shown on mobile. Also, during page load the images are laid out in a stacked column before collapsing, but I think that's just how the template works (it's not unique to the sidebar use).

It's a pretty nifty way to elevate some content in an article to the intro. Thoughts on supporting this as a real thing, like maybe a new template or having a setting on this template so people could discover this usage? Efbrazil (talk) 20:49, 9 May 2020 (UTC)

Mobile view problems

Slideshows are not yet enabled for mobile view: phab:T194887. As noted on the template docs, this can cause either only 4 images to be displayed, all images to be displayed in a grid, or all images to be displayed in a stack.

The best solution is to enable slideshow mode on mobile, but in the meantime perhaps how this module and its templatestyles handle it can be improved... (pinging @Moxy) - Evad37 [talk] 02:35, 5 January 2021 (UTC)

The template has many problems (as seen below). The template was added to portals all over before it was debugged...not only added but old system deleted. Slowly people have been fixing portals with Template:Portal pictures and Template:Random item. There was a tak about deletion of the template... but I believe it just fizzled out because so many pages are involved.
  • T196722: Gallery slideshow controls take up more than one line on narrow displays
  • T196723: Gallery slideshow flickers when changing images
  • T194887: Mode slideshow of gallery tag is not working in phone screens
--Moxy 🍁 02:53, 5 January 2021 (UTC)

Reserved word list needs expanding

Evad37, Frietjes, Moxy, Izno: {{Transclude files as random slideshow}} creates gallery markup from file markup, and in doing so it correctly removes center parameters, but it doesn't remove centre parameters. I edited History of London just now to change three image options from centre to center, but this shouldn't have been necessary and there may be more like it, so will someone please fix the reserved word list of this template? —Anomalocaris (talk) 00:26, 10 March 2021 (UTC)

A related bug is apparent in Portal:Spain, where {{Transclude files as random slideshow ... | Spaniards ... }} has problems with this valid markup in Spaniards:

[[File:Llengües d'Espanya.svg|thumb|right|upright=1.35|'''The vernacular languages of Spain''' (simplified)
{| style="width:100%; background:none;"
| style="text-align: top;" | {{legend|#ddf1b4|'''[[Spanish language|Spanish]]''' official; spoken all over the country}}
{{legend|#f59053|'''[[Catalan language|Catalan]]''', co-official }}
{{legend|#808080|'''[[Basque language|Basque]]''', co-official }}
{{legend|#2b83ba|'''[[Galician language|Galician]]''', co-official }}
| style="text-align: top;" |
{{legend|#d7191c|'''[[Occitan language|Occitan]] ([[Aranese language|Aranese]])''', co-official}}
{{legend|#91cba8|'''[[Asturleonese language|Asturian (and Leonese)]]''', recognised but not official}}
{{legend|#fede99|'''[[Aragonese language|Aragonese]]''', recognised but not official }}
|}]]

Anomalocaris (talk) 01:49, 10 March 2021 (UTC)

Anomalocaris, the centre parameter is easy to fix. unfortunately, embedded tables are not easy to fix. the problem is that while you can use wikitables inside of image captions, you can't use them inside of gallery tag captions. we could have the module remove the wikitables, but correcting them would be a lot of parsing. what probably would work is to replace the wikitable markup with {{Image key}} like this edit. Frietjes (talk) 15:13, 10 March 2021 (UTC)
Frietjes: Thank you for showing me how to use {{Image key}} to replace table captions. The next one to go was Portal:Schools sucking up table markup from History of education, so I used your technique there and that fixed the Misnested tag with different rendering in HTML5 and HTML4 in the portal.

Portals with many images

@Evad37 and Northamerica1000: Portal generation can be slow and sometimes breaches the 10-second limit. Portal:Pakistan was showing "The time allocated for running scripts has expired."; I purged it at a quiet time but it's still over 9 seconds and may flip back randomly. 66% of that is one call to {{Transclude files as random slideshow}} which generates 145 images. What should we do?

One option is to have the module apply a maximum image count. It might be better to tune individual portals, reducing the list of articles from which images are extracted. At least that way we have some say in which ones are removed. Another idea is to limit the number of images per article (currently hard-coded as 100 in the module, which in practice means "all"). However, doing so naively would drop the later images which might be the best ones. Ideally, the module would select the "best" pictures, but that probably involves doing all the current work (and more) before discarding the mediocre, which improves the portal but doesn't solve the timing problem.

I think that choosing 50 at random is as simple as adding the , 1, 50 in local galleryContent = table.concat(sortedLines, '\n', 1, 50), though pruning the selection earlier might be more efficient and we may want to accept a parameter to override the value of 50 that I plucked from thin air. Any thoughts? Certes (talk) 12:47, 30 September 2020 (UTC)

  • I noticed that Pakieditor significantly expanded the General images section on 20 September 2020 (diff), which is very likely contributing to the Lua timeout errors. An immediate fix would be to prune some of the entries from the General images section. From past experience, this tends to stop the timeouts. North America1000 13:20, 30 September 2020 (UTC)
@Certes: That's rather late in the piece to be limiting the number of images. The expensive (time-consuming) work is likely to be in the extractRegularFiles function, which does a bunch of string manipluation and (potentially) preprocessing of templates in a loop. - Evad37 [talk] 13:29, 30 September 2020 (UTC)
You're right; it's too late. extractRegularFiles is efficient: gsub takes 0.32 seconds, some of which lies elsewhere. I suspect the time goes even earlier, in the parse function of Module:Excerpt/portals (which is mainly my fault, though the attribution has become separated). The killer there is retrieving up to 100 file description pages to check for non-free licences. We should probably set files=1-50 rather than 100 in this module but also remove some articles from the list in Portal:Pakistan and similar cases. Certes (talk) 13:59, 30 September 2020 (UTC)
I've removed subnational articles such as Quetta from Portal:Pakistan. It now renders in 6 seconds, of which only 2 s is the slideshow. As an experiment, I've introduced some variety via a region of the day: one final article of {{Random item|Islamabad|Lahore|Karachi|Quetta|Peshawar|Northern Pakistan}} rotates the evicted images. Certes (talk) 14:41, 30 September 2020 (UTC)
@GKFX: I see the maximum number of images is down to 4. This seems rather low compared to the 50/100 discussed above. Is a new problem occurring with higher numbers? Certes (talk) 00:15, 9 May 2021 (UTC)
@Certes: Portal:Arithmetic passes article names not filenames and was struggling at 5 articles. I will revert and make changes to the portal instead. User:GKFXtalk 08:39, 9 May 2021 (UTC)
@GKFX: That portal is taking 9.7 seconds (close to the maximum of 10). 37% is in {{Transclude files as random slideshow}}. Although there are only five arguments, each of them has several files (images). However, there are only 14 altogether and I can't see why this is slow. Maybe Evad37 can advise us. Another 29% is in {{Transclude list item excerpts as random slideshow}}. That runs on Portal:Arithmetic/Selected article, which lists about 60 articles. I tried adding |limit=30 to that call, but it didn't seem to help. It runs again on Portal:Arithmetic/Biographies but that list is short. Certes (talk) 11:05, 9 May 2021 (UTC)