Jump to content

Topic on Project:Support desk

Join two files like href and img src in HTML by means of Wiki markup?

4
Danny373 (talkcontribs)

Hi!

I have an untypical question. It is possible to join two files (Media: and File:) in one link in the Wiki markup language?

For example:

[[Media:Python_Programming.pdf|[[File:Farm-Fresh_file_extension_pdf.png]]Python Programming]]
↑                                                                                           ↑
|--------------------------- one link to the pdf file with pdf icon ------------------------|

Of course, the above example does not work, but the same code as above in HTML language would look like this:

<a href="http://upload.wikimedia.org/wikipedia/commons/9/91/Python_Programming.pdf">
<img src="http://upload.wikimedia.org/wikipedia/commons/8/84/Farm-Fresh_file_extension_pdf.png" />Python Programming</a>

So far I have managed to do something like that code:

[[File:Farm-Fresh_file_extension_pdf.png|link={{filepath:Python_Programming.pdf}}]][[Media:Python_Programming.pdf|Python Programming]]

Which gives the following effect:

Python Programming

But unfortunately this is not a single link as the whole. (The PDF icon is one link and text is another link to the same location)

I will be grateful for some help or any hits.

Best regards,
--
Danny

Krinkle (talkcontribs)

I don't think it gets better than what you're suggesting in the end. Two links with {{filepath:}} to generate an external link and feed it to the |link= parameter of the first link.

If you need this in many places you could create a template:

Template:PdfLink:

[[File:Farm-Fresh_file_extension_pdf.png|link={{filepath:{{{1|Example.png}}}}}]][[Media:{{{1|Example.png}}}|{{{2|{{{1|Example.png}}}}}}]]

And use {{PdfLink|Python_Programming.pdf|Python Programming}} to create:


Python Programming

Danny373 (talkcontribs)

Krinkle, thank you for your help. Admittedly it isn't exactly what I expected, namely one link like in HTML:

<a href="http://upload.wikimedia.org/wikipedia/commons/9/91/Python_Programming.pdf">
<img src="http://upload.wikimedia.org/wikipedia/commons/8/84/Farm-Fresh_file_extension_pdf.png" />Python Programming</a>


But your solution is also cool. I've created a "PDFLink" template according to your idea, and it works great. Thanks!

Krinkle (talkcontribs)

If you want all pdf links on an entire wiki to have this icon, then you shouldn't put the icon in the wikitext. Instead use CSS in MediaWiki:Common.css of your wiki. That way you only have to do this:

*{{filepath:Python_Programming.pdf}}
*[{{filepath:Python_Programming.pdf}} Python Programming]

and get this:

  • //upload.wikimedia.org/wikipedia/commons/9/91/Python_Programming.pdf
  • Python Programming icon
Reply to "Join two files like href and img src in HTML by means of Wiki markup?"