This box includes basic usage information for this template. When calling the template, this documentation will not appear. Functional template code should be placed outside the dotted box.
| Description | Embed widgets from various providers that support the oEmbed standard. |
| Requirements | MindTouch 10.0 or later |
| Documentation URL | |
| Discussion URL |
Make sure to place newest version at the top of the table. Update the table regularly to make it easy to track changes and improvements.
| Version | Date | Author | Description |
|---|---|---|---|
| 0.1 | 08-Dec-2010 | SteveB | first version |
List each parameter of the template in order they are expected. For each parameter, state the set of expected types (bool, num, str, list, map, or xml). Specify if a default value is used when the parameter is omitted.
| Name | Type | Default | Description |
| url | str | The URL to retrieve embedding information for. | |
| maxwidth | num | The maximum width of the embedded resource. | |
| maxheight | num | The maximum height of the embedded resource. |
var url = $0 ?? $url;
var maxwidth = $1 ?? $maxwidth;
var maxheight = $2 ?? $maxheight;
if(!#url) {
"Missing URL";
return;
}
// fetch embeddable resource definition
var oembed = json.parse(web.text(url & { format: 'json' })) !! nil;
if(oembed is nil) {
"Unable to read from oEmbed url: ";
web.link(url);
return;
}
// determine type of embeddable resource
var embed;
switch(oembed.type) {
case 'photo':
let embed = <img src=(oembed.url) title=(oembed.title) />;
case 'video':
case 'rich':
let embed = web.xml(oembed.html);
case 'link':
"Link oEmbed type is not supported.";
return;
default:
"Unrecognized oEmbed type: "; oembed.type;
return;
}
// check if we were able to construct a result to embed
if(!#embed) {
"Unable to parse oEmbed";
return;
}
// embed result
embed;
| Images 0 | ||
|---|---|---|
| No images to display in the gallery. |
Copyright © 2011 MindTouch, Inc. Powered by