Jump to content

Manual talk:$wgAllowExternalImages

Add topic
From mediawiki.org
Latest comment: 21 hours ago by Richie765 in topic Adding support for more formats


  • A way to limit this to certain domains and even directories (and all subdirectories) of a particular domain
  • Allow image alt/title tags for descriptions, borders, and full HTML/CSS customization

-Eep² 09:16, 25 July 2007 (UTC)Reply

As to the first question: $wgAllowExternalImagesFrom covers this.
As to the second question: It should be easy to create an extension for this.
-- Tbleher 10:32, 22 January 2008 (UTC)Reply
  • Enable external image to link to wiki pages, so in addition to [http_URL image_URL], please also implement [[wiki_keyword image_URL]]


Other URL types besides http:[edit]

We have allowed file:// urls to be linked from our wiki using $wgUrlProtocols, but this does not appear to apply to images. This would help us in our work to allow an image to be revised outside of the wiki on a file server and appear in a wiki article without repeated uploading. Bill Johnson 21:12, 6 December 2007 (UTC)Reply

So you want to put in an external image link but using a local file URL such as file:///h:\network-path\image.jpg  ? Yeah you're right. I just tried that on my company wiki. MediaWiki doesn't pick up on the '.jpg' and spit out an IMG tag as you might expect.
It's a bit of an ugly thing to do, and highly non-standard. Internet explorer does support it though <IMG SRC="file:///h:\network-path\image.jpg">. So you could make a simple mediawiki extension to output that HTML.
-- Harry Wood 15:27, 7 December 2007 (UTC)Reply

images from Google Docs[edit]

is not work if use images from google docs like http://docs.google.com/drawings/pub?id=14dkOMelgnXsjC-EC9vXIo6MLVZoabRzsRlNnKjwbe4M&w=960&h=720

Add a '&.png' to the end of the url.
-- Daniel Stonier, June 2013.
The &.png trick doesn't work for me. The browser gives me a PNG to download when I load the page
-- Paul Rafferty, April 2014
Paul - For Google Drive documents I used something like &fake=.png at the end and it worked.

...images only from Flickr... doesn't seem to work, help please[edit]

I tried set this up so that just the wiki only excepts images from flickr.com or http://farm3.static.flickr.com/ Doesn't seem to restrict just to the Flickr address --Willjermuk 22:42, 16 April 2008 (UTC)Reply

See $wgAllowExternalImagesFrom. --Sayuri 15:45, 21 April 2008 (UTC)Reply

Image size[edit]

Is it possible to set the image to a different size, as it is with uploaded images (syntax is, e.g., |200px). --Robinson Weijman 08:21, 5 January 2009 (UTC)Reply

It is a bit brute force, but if you have $wgRawHTML set to "true", you can use...

<html> <img style="max-width: XXXpx; max-height: YYYpx;" src="http://location-of-image.jpg"> </html> 21:51, 12 December 2010 (UTC)Reply
Thanks very much (whoever you are :) )! --Robinson Weijman 13:35, 3 January 2011 (UTC)Reply

URL limitation[edit]

Based on my reading of Parser.php, this feature only works if the URL ends with a filename suffix indicating GIF, PNG, or JPEG. (Similar to how Internet Explorer "outsmarts" server-supplied MIME types.) So this won't work with, e.g. http://example.com/temperature_graph.cgi, whose HTTP header indicates an image MIME type. --Fleminra 21:39, 28 August 2009 (UTC)Reply

How to maintain external images I embedded?[edit]

There is no way to maintain the embedded external images (list all / find dead ones). See https://bugzilla.wikimedia.org/show_bug.cgi?id=38468

--Subfader (talk) 10:24, 18 July 2012 (UTC)Reply

Adding support for more formats[edit]

Didn't find this info elsewhere, so figured I'd post it in case anyone else wanted to know. If you want to add support for external AVIF, JPEG XL, WEBP, SVG, etc. images it's very simple (as it's the browser that's actually handling the image). You just need to edit 1 line in /mediawiki/includes/parser/Parser.php:


and add the file extensions you want to support with a | between, like so:

\\/([A-Za-z0-9_.,~%\\-+&;#*?!=()@\\x80-\\xFF]+)\\.((?i)gif|png|jpg|jpeg|jxl|avif|webp|svg|apng|bmp)$/Sxu'; 2601:603:1500:74:984D:CD81:3302:4204 05:44, 17 April 2024 (UTC)Reply

This has now been implemented in MediaWiki itself. See https://gerrit.wikimedia.org/r/c/mediawiki/core/+/1035038 However I'm not sure with which version it starts. --Richie765 (talk) 08:40, 17 June 2024 (UTC)Reply