Jump to content

Extension:IframePage

From mediawiki.org
MediaWiki extensions manual
IframePage
Release status: beta
Implementation Special page
Description Allows embedding an iframe into a special page
Author(s) Ike Hecht (tosfostalk)
Latest version 0.2.1 (March 2020)
MediaWiki 1.29+
PHP 5.5+
Database changes No
License GNU General Public License 2.0 or later
Download
  • $wgIframePageSrc
  • $wgIframePageAllowPath
Quarterly downloads 25 (Ranked 105th)
Translate the IframePage extension if it is available at translatewiki.net

The IframePage extension allows embedding an iframe into a special page. The iframe src is set in "LocalSettings.php" so that it does not pose a security risk. It is useful for embedding functionality from an external site and visually integrating it as if it was contained in the wiki.

Installation

[edit]
  • Download and move the extracted IframePage folder to your extensions/ directory.
    Developers and code contributors should install the extension from Git instead, using:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/IframePage
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'IframePage' );
    $wgIframePageSrc = [ /* REQUIRED! */ ];
    
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Configuration

[edit]
$wgIframePageSrc
An associative array containing the iframe src. Mandatory.
The key in this array is expected to be a simple string that will be used as the title of a subpage of Special:IframePage. The value should contain the actual iframe src URL.
The key can be omitted. That is because navigating to Special:Iframepage will simply pull the URL contained in the first value in the $wgIframePageSrc array.
$wgIframePageAllowPath
Defaults to false. If set to true, it allows passing a parameter using ?path=.... The path value will be appended to the URL contained in $wgIframePageSrc.

Examples

[edit]

These examples are described using YouTube or Vimeo and are just for illustration.

Simple example

[edit]
$wgIframePageSrc = [ 'YouTube' => 'https://www.youtube.com/embed/DWef69ItVrU' ];

In this case, navigating to Special:Iframepage/YouTube or to Special:Iframepage will display a video with the ID specified in the $wgIframePageSrc array.

Example using a path

[edit]
$wgIframePageSrc = [
    'YouTube' => 'https://www.youtube.com/embed/',
    'Vimeo' => 'https://player.vimeo.com/video/'
];
$wgIframePageAllowPath = true;

In this case, navigating to Special:Iframepage/YouTube or to Special:Iframepage will cause a YouTube error, since no ID was specified. You can send an ID by specifying the path. For example, you can navigate to Special:IframePage/YouTube?path=DWef69ItVrU to see the above video. Or substitute the path with any YouTube video ID.

Alternatively, to see a Vimeo video, navigate to Special:IframePage/Vimeo?path=42683487, substituting the path with any Vimeo ID.

Warning Warning: When setting $wgIframePageAllowPath be sure that the domain names in $wgIframePageSrc a terminated with a / or a ?. For example, if you had $wgIframePageSrc = [ 'YouTube' => 'https://www.youtube.com' ], the list could effectively be bypassed by having a path of ".someotherwebsite.com". Instead you should specify https://youtube.com/

Including on another page

[edit]

It is possible to include the IframePage on another page. Use {{Special:IframePage}} when editing the page.

If you need to pass in the url then use pipes the same way you would for other mediawiki templates: {{Special:IframePage/Youtube|path=sYgxTkg2j5Hxoeei/embed}}

or

{{Special:IframePage/Vimeo|path=42683487}}

Adding rel=nofollow

[edit]

To keep search engines from crawling the external websites, as most iframes will be external websites, this can be done a few ways. The recommended option is editing the SpecialIframePage.php and adding to the $html .= Html::element array so the last two lines of the array look like this:
'height' => '100%',
'rel' => 'nofollow'
Note: there must be a comma (,) at the end of the previous "height" array.
The second option is to add disallow: /Special:IframePage to your robots.txt file in the wiki installation directory. This is the less preferable option as the entire page will not show up in the search enginge results rather than the links within the iframe.

See also

[edit]