Template:PDFlink/doc

undefined highlights that a link points to a PDF document (on some systems PDF files may take time to download and display within the browser, and their use on many websites is not compliant with the Web Content Accessibility Guidelines).

Usage
The following lines:

yield:



Note: It was previously possible to add the icon with  by itself, but the functionality has changed, making this no longer work in Internet Explorer. You must surround it with the template as shown above to work correctly in Internet Explorer. See, below, for how to do this now without boogering IE.

Units: Use KB and MB (kilobytes and megabytes), not KiB and MiB (kibibytes and mibibytes), as very few readers have ever even heard of the latter units.

Icon
The icon is added using CSS and is found in MediaWiki:Common.css, the relevant portion that applies the icon is:

The problematic "=" character
When this template is used with unnamed parameters, links containing the " " (equals sign) character will cause the link to not display at all. Workarounds available are: or or
 * Use explicitly numbered parameters, 1 and 2, for the URL and the file size, respectively
 * Use  as a replacement for
 * Replace the  character with its numeric character entity reference,


 * Bad example:


 * Good examples:



Use in citation templates
This template is not instantly compatible with citation templates such as cite book and cite web, which put URLs in their own parameter, without markup. Two kinds of usage need two different workarounds, both using the invisible but existent "no-width space" numeric character entity reference,.


 * URLs ending in ".pdf" or ".PDF":

The workaround is to not use an actual URL (and no [square brackets]) in the PDFlink first parameter, but just the  entity:

|title=Some Article |url=http://www.example.org/fileserver/Link.pdf |format=

renders as something like:


 * Some Article

in the spaces that the parameters fill. (Exact spacing, punctuation, etc., depends on the specific citation template used). This prevents the appearance of a PDF icon auto-generated by MediaWiki being followed by one generated by PDFlink.

Doing this, however: |title=Some Article |url=http://www.example.org/fileserver/Link.pdf |format=

would result in:


 * Some Article

This trick needs to be done with the character entity, because leaving the first parameter blank will simply get the page categorized in a cleanup category for pages that misuse this template, and a bot will "fix" the page's use of the template (i.e., it will cause problems).


 * URLs not ending in ".pdf" or ".PDF":

The workaround is to repeat the URL used in url in PDFlink inside format as a square-bracketed link, and use  as the link text (note that numbered parameters are often required because of " " characters in such URLs):

|title=Some Article |url=http://www.example.org/fileserver&file=2234234 |format=

yields:


 * Some Article

I.e., it produces a PDF icon that links to the same target as the URL given in the citation template's url parameter, without creating new link text, and meanwhile MediaWiki did not know this was a PDF file and so did not autogenerate a duplicative icon.