Help:Linked images

From PostgreSQL wiki

Images on a MediaWiki wiki are designed to link to the description page, so that licensing information, upload history, contributors, and full resolution versions are immediately available to the user when he or she clicks an image. In fact, MediaWiki is designed to prevent manual manipulation of images in wikicode which may circumvent this operation: The <img> tag is specifically not whitelisted in the Sanitizer, nor is the background-image CSS attribute.

Contents

Vanilla install

If you only have sysop access to the Wiki, these are your best options.

Site CSS

The most simplistic method, if your requirements for external images are specialized (that is, restricted to one page or one image), is to add a CSS rule to your MediaWiki:Common.css (or other CSS files, such as MediaWiki:Skinname.css or /skins/skinname/main.css, etc) giving child links of a certain class of object a background image. This method also has some security, as it requires editing the site-wide CSS files, meaning only sysops have access to modify the image shown.

This would give the link the background image specified, as well as the width and height of the image (which you have to set manually). To find the location of an uploaded file, go to the image description page and click the image itself, and copy the image location in the address bar.

Known problems: It doesn't work in text-only browsers, and in screen readers for the disabled, and possibly other situations. The technique of using CSS to change page content also completely breaks an article's web accessibility by contravening a WAI priority-one checkpoint.[1]

Redirect

A less elegant trick is to make the image description page a redirect to the target. So for example Image:Wiki.png would be changed to content:

#REDIRECT [[MediaWiki]]

There are several disadvantages to this:

It doesn't always work, some installations/versions have internamespace redirects disabled.

The image appears at the top of the article. This is because MediaWiki redirects aren't really redirects, they simply bring the target page's data to the current URL, but on image description pages this is done after the image itself is shown.

It can only be done once per image.

Native with configuration change

If you have server access, but do not want to install any extensions, these solutions may work for you.

External image syntax

If you enable $wgAllowExternalImages (which allows external images from any domain) or $wgAllowExternalImagesFrom (which restricts the list of domains), anyone can then easily create an "external" link to an "external" image. External simply means: using the full URL rather than a local link, so you can link locally, but you need to use the full URL. The plainlinks class is used to remove the "external link" icon: