Jump to content

Extension:CloudImage: Difference between revisions

From mediawiki.org
Content deleted Content added
Cory (talk | contribs)
2023.07.12 (v1.1.1) support Dropbox and imgur
Cory (talk | contribs)
v1.1.2, SlideShare and Speaker Deck (oEmbed) experimental support.
Line 5: Line 5:
|username = Cory
|username = Cory
|author = [https://kimagurenote.net/ Kimagurenote]
|author = [https://kimagurenote.net/ Kimagurenote]
|description = embed image directly from [[w:Flickr|Flickr]], [[w:OneDrive|OneDrive]], [[w:Dropbox|Dropbox]] and [[w:Imgur|imgur]]
|description = embed image directly from [[w:Flickr|Flickr]], [[w:OneDrive|OneDrive]], [[w:Dropbox|Dropbox]] and others
|image = MediaWiki_Extension_CloudImage_example_OneDrive.jpg
|image = MediaWiki_Extension_CloudImage_example_OneDrive.jpg
|mediawiki = 1.35+
|mediawiki = 1.35+
|version = 1.1.1
|version = 1.1.2
|php = 8.0+
|php = 8.0+
|hook1 = ParserFirstCallInit
|hook1 = ParserFirstCallInit
Line 20: Line 20:
}}
}}


The '''{{BASEPAGENAME}}''' extension provides a way to embed images directly from [[w:Image hosting service|image hosting services]] e.g. [[w:Flickr|Flickr]], [[w:OneDrive|OneDrive]], [[w:Dropbox|Dropbox]], [[w:Imgur|imgur]] and others.
The '''{{BASEPAGENAME}}''' extension provides a way to embed images directly from [[w:Image hosting service|image hosting services]] e.g. [[w:Flickr|Flickr]], [[w:OneDrive|OneDrive]], [[w:Dropbox|Dropbox]], [https://www.slideshare.net/developers/oembed SlideShare], [https://speakerdeck.com/faq#oembed Speaker Deck], [[w:Imgur|imgur]] and others.


== Installation ==
== Installation ==
Line 155: Line 155:


=== Timeout ===
=== Timeout ===
It timed out 60 seconds by default to call Flickr API.
This extension timed out 60 seconds by default to call Flickr API.


If you use it to embed Flickr images, we recommend to set [https://www.php.net/manual/en/filesystem.configuration.php#ini.default-socket-timeout "default_socket_timeout" on php.ini] shorten.
If you use it to embed Flickr images, we recommend to set [https://www.php.net/manual/en/filesystem.configuration.php#ini.default-socket-timeout "default_socket_timeout" on php.ini] shorten.
Line 182: Line 182:


== Notice ==
== Notice ==
SlideShare (oEmbed), Speaker Deck (oEmbed) and imgur support are experimental.

This extension has some privacy risk. <span style="color: red;">Use only at private site!</span>
This extension has some privacy risk. <span style="color: red;">Use only at private site!</span>



Revision as of 12:14, 13 July 2023

MediaWiki extensions manual
CloudImage
Release status: stable
Implementation Tag
Description embed image directly from Flickr, OneDrive, Dropbox and others
Author(s) Kimagurenote (Corytalk)
Latest version 1.1.2
MediaWiki 1.35+
PHP 8.0+
Database changes No
‎<cimg> ‎<flickr>
Licence 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

The CloudImage extension provides a way to embed images directly from image hosting services e.g. Flickr, OneDrive, Dropbox, SlideShare, Speaker Deck, imgur and others.

Installation

At first, you must get Flickr API Key if you want to embed images from Flickr.

  • Download zip file from author's website, unzip it and place the file(s) in a directory called CloudImage in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php file:
    /* (option) if you want to use <flickr> tag compatibility */
    $wgCloudImageCompatibleFlickrAPI = true;
    /* CloudImage */
    wfLoadExtension( 'CloudImage' );
    /* (option) if you want to embed images from Flickr */
    $wgFlickrAPIKey = "(your api key here)";
    /* (option) if you want to embed images from local server */
    $wgCloudImageAllowedDomains['www.yourdomain.com'] = '';
    /* (option) if you want to embed highly resolution image from Flickr */
    $wgCloudImageFlickrLargeSize = "Large";
    
  • Configure $wgMainCacheType if you want to use caching mechanism for saving to call Flickr API.
  • 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;
}
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Usage

embed simply

Just embed a image simply. But not forgot to close the tag by "/>". For example:

<cimg src="https://example.com/image.jpg" width="600" />

Note: border="0" set automatically if not set.

embed with comment

You can specify some parameters similarly ‎<img> tag.

You can use "href" to attach a hyper link on the image.

And you can 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 using here.

  • framestyle - styles for ‎<figure>
  • captionstyle - styles for ‎<figcaption>

embed from Dropbox

You can embed Dropbox link of images 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 a tag ‎<flickr> that has semi-compatibility with Extension:FlickrAPI for migration.

If you want to use this function, set the value above wfLoadExtension.

/* CloudImage */
$wgCloudImageCompatibleFlickrAPI = true;
wfLoadExtension( 'CloudImage' );

High resolution images

This extension has automatically selected similar size thumbnails from Flickr by default.

Or you can use large size thumbnails for high resolution screens.

If you want to use this function, set the value on LocalSettings.php.

$wgCloudImageFlickrLargeSize = "Large";

Sites limitation

You can embed images from Flickr and OneDrive by default.

And you can add other sites if you want.

$wgCloudImageAllowedDomains['www.yourdomain.com'] = '';

Note: This variable must set the value (empty string).

Attributes limitation

You can use attributes 'width', 'height', 'class', 'style', 'title' and 'alt' by default.

And you can add other attributes if you want.

$wgCloudImageAllowedAttrs = [ 'width', 'height', 'class', 'style', 'title', 'alt' ];

This extension refer the $wgExternalLinkTarget value.

$wgExternalLinkTarget = '_blank';

Timeout

This extension timed out 60 seconds by default to call Flickr API.

If you use it to embed Flickr images, we recommend to set "default_socket_timeout" on php.ini shorten.

Object cache

This extension use MediaWiki Object cache mechanism for saving to call Flickr API.

If you use this extension to embed Flickr images, we recommend to set $wgMainCacheType.

And if you want clear the cache, set the value on LocalSettings.php and reload the image.

$wgCloudImageCachingTime = false;

Note: Purge not affect this extension.

Custom tag

You can use another tag e.g. ‎<img> as alias.

If you want to use this extension with ‎<img>, set the value above wfLoadExtension.

/* CloudImage */
$wgCloudImageTag = "img";
wfLoadExtension( 'CloudImage' );

Notice

SlideShare (oEmbed), Speaker Deck (oEmbed) and imgur support are experimental.

This extension has some privacy risk. Use only at private site!

For details see here: Manual:$wgAllowExternalImages#Why disallow external images?

See also