Topic on Project:Support desk

Find out whether file has a thumbnail image

4
Jonathan3 (talkcontribs)

I have a template that displays the thumbnail of the relevant file, which usually is a PDF. I have a small number of PDFs which (for whatever reason) no thumbnail can be generated. Also some files are DOC files which similarly have no thumbnail.

The problem is that when there is no thumbnail, the text File:Filename.pdf is displayed: I'd rather have no text displayed if there is no thumbnail.

Is there a way (magic word, extension etc) to find out within the template whether the file has a thumbnail? Or some other way of ensuring no text is displayed in lieu of the missing thumbnail?

For the time being, I'm using #pos to work out whether the filename contains ".pdf", which cuts out the DOC files, but I'd like to be able to identify the PDFs with no thumbnail as well.

Thank you.

Bawolff (talkcontribs)

maybe scribunto you could look up the images width/height. Typically, images that cant be displsyed are treated as having 0x0 dimensions.

Jonathan3 (talkcontribs)

Thanks. Yes, they are all shown as "0x0". I've avoided learning Lua/Scribunto so far, but when I eventually do, I'll remember this and have a go. Jonathan3 (talk) 07:44, 18 April 2021 (UTC)

TheDJ (talkcontribs)
Reply to "Find out whether file has a thumbnail image"