Extension:CloudImage
![]() Release status: stableCategory:Stable extensions |
|
---|---|
![]() |
|
Implementation | TagCategory:Tag extensions |
Description | embed image directly from Flickr, OneDrive, Dropbox and others |
Author(s) | Kimagurenote (Corytalk) |
Latest version | 1.1.5 |
MediaWiki | 1.35+Category:Extensions with manual MediaWiki version |
PHP | 8.0+ |
Database changes | No |
License | BSD 3-clause "Modified" License |
Download | https://kimagurenote.net/kn/CloudImage#Download https://kimagurenote.net/kn/CloudImage#History |
Example | https://kimagurenote.net/kn/CloudImage#Usage_%E4%BD%BF%E3%81%84%E6%96%B9 |
<cimg> <flickr> |
|
The CloudImage extension provides a way to embed images directly from image hosting services such as Flickr, OneDrive, Dropbox, SlideShare, Speaker Deck, imgur and others, via the <cimg>
tag, which functions similarly to the <img>
tag.
Installation
- Download the zip file from the author's website, unzip it and place the file(s) in a directory called
CloudImage
in yourextensions/
folder. - Add the following code at the bottom of your LocalSettings.php file:
/* Extension:CloudImage */ wfLoadExtension( 'CloudImage' ); /* (optional) if you want to embed images from local server */ $wgCloudImageAllowedDomains = [ "www.yourdomain.com", "wiki.yourdomain.com" ]; /* (optional) link target */ $wgExternalLinkTarget = '_blank'; /* (optional) lazy loading */ $wgNativeImageLazyLoading = true;
- Additional configuration if you want to use Extension:FlickrAPI (
<flickr>
tag) compatible mode. - Add the following code at the bottom of your MediaWiki:Common.css. You can fully customize it.
/* Extension:CloudImage */
IMG.cimg {
max-width: 100%;
}
FIGURE.cimg {
clear: both;
margin: 2px;
border: 1px solid #c8ccd1;
background-color: #f8f9fa;
font-size: 94%;
}
FIGCAPTION.cimgcaption {
padding: 2px;
text-align: left;
}
Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Note: You will need interface-admin permission to edit Common.css on MediaWiki 1.32 or above.
Usage
Simple embedding
Simply add the tag with the image path specified in the "src" attribute. Remember to close the tag with "/>". For example:
<cimg src="https://example.com/image.jpg" width="600" />
Note: border="0" is set automatically if it is not specified.
Embed with caption
You can specify some attributes in a similar way to the <img>
tag.
You can use the "href" attribute to attach a hyper link to the image.
And you can also write a comment below the image.
For example:
<cimg src="https://example.com/sample.jpg"
href="https://example.com/"
width="400" height="300"
title="test image"
alt="test image"
framestyle="clear: right; float: right;"
captionstyle="text-align: right;">
comment here
</cimg>
Special attributes used here.
- framestyle - styles for
<figure>
- captionstyle - styles for
<figcaption>
Embed from Dropbox
You can embed Dropbox image links directly. For example:
<cimg src="https://www.dropbox.com/s/9qwyhjuliy2whlu/18m4362_1920x1200.jpg?dl=0">[[w:Tadami Line|Tadami Line]] in winter</cimg>
Embed from Flickr
You can embed images hosted on Flickr directly. For example:
<cimg src="https://www.flickr.com/photos/kimagurenote/26817918388/in/album-72157649433330773/">Photo from [[Flickr]]</cimg>

Configuration
Compatibility with Extension:FlickrAPI
This extension provides the tag <flickr>
, which is semi-compatible with Extension:FlickrAPI for migration.
To use this function, set the $wgCloudImageCompatibleFlickrAPI value above wfLoadExtension.
And set your Flickr API Key to $wgFlickrAPIKey. You can use the same key as in Extension:FlickrAPI.
/* Extension:CloudImage */
$wgCloudImageCompatibleFlickrAPI = true;
wfLoadExtension( 'CloudImage' );
$wgFlickrAPIKey = "(your api key set here)";
Note: This extension use Flickr API key with Extension:FlickrAPI (<flickr>
tag) compatible mode only.
Object cache
This extension uses MediaWiki's Object cache mechanism to save calls to Flickr API (excluding oEmbed).
If you use Extension:FlickrAPI compatibility mode, we recommend setting $wgMainCacheType.
And if you want to clear the cache, set the value in LocalSettings.php and reload the image.
$wgCloudImageCachingTime = false;
Note: Purging does not affect this extension.
Supported domains
By default, you can embed images from Flickr, OneDrive, Dropbox, Google Drive, SlideShare, Speaker Deck and imgur.
You can also add other sites if you wish.
$wgCloudImageAllowedDomains = [ "www.example.com", "image.example.net" ];
Note: This variable is changed in v1.1.4. The former format is no longer recommended.
Supported values
By default, you can use the 'width', 'height', 'class', 'style', 'title' attributes.
You can also add other attributes if you wish.
e.g. adding 'id'
$wgCloudImageAllowedAttrs[] = 'id';
Alternatively, you can overwrite the setting to limit the list to specific attributes.
e.g. blocking 'class' and 'style'
$wgCloudImageAllowedAttrs = [ 'width', 'height', 'title', 'alt' ];
Note: Attribute values must be lowercase letters.
Link target
This extension refers to the value of $wgExternalLinkTarget.
$wgExternalLinkTarget = '_blank';
Lazy loading
This extension supports the use of the lazy loading mechanism since v1.1.5.
You can set $wgNativeImageLazyLoading in LocalSettings.php if you want to use this function.
$wgNativeImageLazyLoading = true;
Note: This parameter is supported since MediaWiki version 1.34.0.
Timeout
This extension is set to time out after 60 seconds when calling the Flickr API by default.
We recommend setting "default_socket_timeout" in php.ini as short as possible.
The Flickr oEmbed call times out after 2 seconds by default.
And you can change it as follows.
$wgCloudImageFlickrTimeout = 1.5;
Custom tag
You can use another tag e.g. <img>
as an alias.
To use this extension with <img>
, set the value above wfLoadExtension.
/* Extension:CloudImage */
$wgCloudImageTag = "img";
wfLoadExtension( 'CloudImage' );
Notice
Support for SlideShare (oEmbed), Speaker Deck (oEmbed) and imgur is experimental.
This extension poses a privacy risk. Only use it on private sites! For more details, see: Manual:$wgAllowExternalImages#Why disallow external images?
See also
- CloudImage (author site, written in Japanese)
- Manual:$wgAllowExternalImages
<img>
: The Image Embed element (MDN)- oEmbed
- Extension:FlickrAPI
- Extension:HTMLets
- Extension:EImage