Jump to content

Topic on Project:Support desk

How to show a little file thumbnail image, for a download?

8
RedKnight7 (talkcontribs)

I want to post an Excel and a PDF for folks to download from my tiny wiki. I can make hotlinked text for users to click on and download the Excel or the PDF, using a Media: link. But I would like to do this with a generic little Excel thumbnail image or a generic little PDF thumbnail image for the user to click on, instead of text saying "here's the Excel", etc.

I imagine this is pretty easy but I don't know what keyword to search on, to find out how to do it.

Also, would I have to make or supply my own little Excel and PDF images, to use for this?

Ciencia Al Poder (talkcontribs)

The easy way is to upload a thumbnail of the Excel/PDF to your wiki, and then make the thumbnail link to the download.

Example:

[[File:ExcelThumbnail.png|80px|link=Media:My excel file.xlsx|Download]]

You can even put that code inside a template, making the link= value a parameter, for easy usage.

RedKnight7 (talkcontribs)

Thanks very much! It all works okay except if I put something like:

[[File:Excel_icon.gif|80px|link=Media:Spreadsheet_data.xlsx|right| Excel of electricity by month]]

It does everything else right (showing a linked icon on right side of page), but there are two problems:

1) If you click on the image , it doesn't go directly to the "download xls to where?" popup, instead it goes to the actual File: page for that file on my wiki. And then the person has to go through a few more clicks to actually download it.

2) It does not show the caption text "Excel of electricity by month" at all.

Thanks so much if you can help. Coding is such a hassle, laugh.

I have MediaWiki 1.35.1

Ciencia Al Poder (talkcontribs)

Oh, well, looks like we've hit bug phab:T18409.

You may try to change the link Media:Spreadsheet_data.xlsx to Special:FilePath/Spreadsheet_data.xlsx

If you want to display a caption, add |thumb|

Jonathan3 (talkcontribs)

I was just working this out yesterday (using images as links) and came across the same problem - it links to the File: page instead of the actual uploaded file.

Anyway, you want something like this in your template, where {{{Download|}}} is the filename and {{{Caption|}}} is the caption text:

[[File:{{{Download}}} | thumb | link={{SERVER}}/media/{{urlencode:{{{Download}}}|WIKI}} | {{{Caption|}}} ]]

If your URL structure has /images/ (I think I changed mine a few years ago but can't remember) then just change that part of the line above. {{SERVER}} should turn into (e.g.) https://www.example.com, or alternatively you can just put the URL into the template if it's never going to change. {{urlencode:...|WIKI}} changes spaces to underscores (so that the link will work) etc.

With the caption problem, some methods of displaying images just don't show the caption. It's all here: Help:Images. If you use |frame or |thumb (as Ciencia said) the caption will show up.

RedKnight7 (talkcontribs)

Thank you everyone, It was hard for me to read the {{{}}} stuff. So if it helps any, this is what worked for me:

[[File:Excel_icon.gif|150px|left|link=http://YourWebsiteName.com/wiki/images/1/15/Your_Great_Spreadsheet.xlsx|thumb|Spreadsheet of electricity usage by month]] 

Problem solved. Love you folks. Ciencia, you've been helping for years!

Bawolff (talkcontribs)
RedKnight7 (talkcontribs)

UPDATE: Problem solved! I just needed to put a colon in front of File: (like :File:) in order to have a link to the file's page, not the file itself. More info at Help:Linking_to_files.

Hi everyone, thanks for your help 8 months ago... a new wrinkle on this, please?

I want to show, e.g., an Excel icon for a spreadsheet download, and have it directly start the download. Okay, this was handled just fine, above.

But now I also want to have, in the description of the thumbnail, a link to the wiki page for that file - so someone can back up and get a previous version if they want. Or if they have any trouble with the direct download link associated with the Excel icon.

The thumbnail description my example above is

Spreadsheet of electricity usage by month

I want to change this to say

Spreadsheet of electricity usage by month. Click on the icon to download the Excel, or click here to go to its file page.

(or something like that).

For the underlined part, if I try putting:

[[File:Your_Great_Spreadsheet.xlsx | click here to go to its file page]]

it only shows File:Your_Great_Spreadsheet.xlsx, and not the text.

If I use Media: instead of File:, it shows the text, but it just directly downloads the Excel - it doesn't take you to the Excel file's wiki page.

Edit: I also tried not having either File: or Media:, but then it just thinks Your_Great_Spreadsheet.xlsx is a new (blank) page (it shows the thumbnail text using the red URL coloring).

How can I get this to work right?

Keep in mind that it' all being wrapped in the outer [[ ... ]] for the image and thumbnail, too.