MediaWiki extensions manual
OOjs UI icon advanced.svg
Embed Anything
Release status: unmaintained
Description Embed anything into your wiki.
Author(s) Jason Dixon
Database changes No
License No license specified
Example <embed template=SmallBox url=http://anything.com></embed>
Check usage and version matrix.

What is it?Edit

This extension is designed as a simple way of bringing rich media to any webpage, by allowing Embeds of other webpages and content with custom templates. It uses a mixture of "Embed", "Readability", "stash" and "HtmlFilter" libraries.


Download from HERE. Rename the folder to "EmbedAnything" if you need to, and place it in your Extensions directory.


In your LocalSettings.php add the line:

require_once "$IP/Extensions/EmbedAnything/EmbedAnything.php";
NOTE: Your extensions directory needs to be accessible from the internet (or at least the EmbedAnything folder in there).

Begin embedding!


Alright so lets get embedding...

There are three ways to embed your link. Replacing "URL" with your link, below:

  • <embed>URL</embed>
  • <embed url=URL></embed>
  • {{#tag:embed|URL}}

It is important to note, if you wish to use embeds with other functions. You must use the third option.


Embed Anything comes with a simple template system for your embeds to match your sites design perfectly.

To use a template within your tag, pass the "template" or "style" attribute, with the template name. ie:

<embed template=MyTemplate url=http://thing.com></embed>

If you are interested in creating your own template (you should be, it's easy!), templates are placed in the following folder:


Templates need to be php files, and need to output their content. Take a peek at what is already there to get an idea of how it works.

Templates receive two important php variables: $data and $options.

  • $options - Provides attributes sent from the user through the tag. This is so templates can have customization from within the tag. For example a width attribute.
  • $data - Provides the actual data for the embed, and for placing into your template. See below for the data transferred.

Embed DataEdit

Within your template, you will receive an array variable $data. Within it you will find the following information you can echo out:

$data[title] The page title
$data[description] The page description
$data[url] The canonical URL
$data[type] The page type (link, video, image(photo), rich). Use this to determine what is shown in your template.
$data[image] The image chosen as main image
$data[defaultImage] The default image if none is found. A simple use a simple (if ? Yes : No) check to determine.
$data[imageWidth] The width of the main image
$data[imageHeight] The height of the main image
$data[code] The code to embed the image, video, etc. NOTE: This is typically iframes and embeds. This can be empty if none of those are provided by your link. In which case, you might want to use an image in your template.
$data[width] The width of the embed code
$data[height] The height of the embed code
$data[aspectRatio] The aspect ratio (width/height)
$data[thumb] Thumbnail of the website itself.
$data[authorName] The (video/article/image/whatever) author
$data[authorUrl] The author URL
$data[providerName] The provider name of the page (YouTube, Twitter, Instagram, etc)
$data[providerUrl] The provider URL
$data[providerIcon] The icon chosen as main icon
$data[content] The pages text content, html-purified

Further CustomizationEdit

There are also a few variables that can be changed to preference. Hiding in a couple files.

In the file data.php

define('EA_SOUNDCLOUD_KEY',null); // Soundcloud key
define('EA_FACEBOOK_KEY',null); // Facebook key
define('EA_EMBEDLY_KEY',null); // Embedly key

// Default Images and Icons if missing
$image_directory = 'extensions/EmbedAnything/includes';
define('EA_DEFAULT_IMG'		, "$image_directory/missing_image.png");
define('EA_DEFAULT_ICON' 	, "$image_directory/missing_icon.png");

// Cache file
define('EA_CACHE_DIR',__DIR__.'/cache'); // Cache directory
define('EA_CACHE_TIME', 1 * 60 * 60 * 24 * 7); // Cache expiry time. Items older than this will be regenerated.

In the file formHtml.php

// Set the default template. The file name without php
define('EA_DEFAULT_TEMPLATE', 'SimpleBox');
define('EA_TEMPLATE_DIR', __DIR__.'/template');

Data CachingEdit

Embed Anything caches information pulled from websites. By default the cache lasts two weeks, and the entire cache gets flushed out every ten weeks. To change this, adjust the cache expiry time above. Generally though, websites that get embedded are unlikely to change their information, and so should be left to cache cleanly. It should also be noted that MediaWiki caches the html output of the template by Embed Anything anyway. The reason for the secondary cache is in speeding up page edits, dynamic __NOCACHE__ pages, storing website thumbnails, and any time the same URL is embedded elsewhere in the site. It also plays nicely with Semantic MediaWikis {{#ask:}} and {{#show:}} functionality. So you can easily and cheaply create huge pages of videos and images by listing links from semantic pages.