Expand all

EmbedFileFormatter

Converts data in various formats needed by the Embed sub-dialog

Constructor

new EmbedFileFormatter() #

Methods

getByline([author], [source], [attribution], [formatterFunction]) → {string} #

Byline construction

Parameters:

Name Type Attributes Description
author string optional

author name (can contain HTML)

source string optional

source name (can contain HTML)

attribution string optional

custom attribution line (can contain HTML)

formatterFunction function optional

Format function for the text - defaults to allowlisting HTML links, but all else sanitized.

Returns:

Byline (can contain HTML)

Type
string
Source:
Byline construction

getCreditHtml(imageInfo) → {string} #

Generates the HTML embed code for the image credit line.

Parameters:

Name Type Description
imageInfo ImageModel

Returns:

Type
string
Source:
Generates the HTML embed code for the image credit line.

getCreditText(imageInfo) → {string} #

Generates the plain text embed code for the image credit line.

Parameters:

Name Type Description
imageInfo ImageModel

Returns:

Type
string
Source:
Generates the plain text embed code for the image credit line.

getThumbnailHtml(info, imgUrl, [width], [height]) → {string} #

Generates the HTML embed code for the image.

Parameters:

Name Type Attributes Description
info Object
Properties:
Name Type Description
imageInfo ImageModel
imgUrl string

URL to the file itself.

width number optional

Width to put into the image element.

height number optional

Height to put into the image element.

Returns:

Embed code.

Type
string
Source:
Generates the HTML embed code for the image.

getThumbnailWikitext(title, [width], [caption], [alt]) → {string} #

Helper function to generate thumbnail wikicode

Parameters:

Name Type Attributes Description
title mw.Title
width number optional
caption string optional
alt string optional

Returns:

Type
string
Source:
Helper function to generate thumbnail wikicode

getThumbnailWikitextFromEmbedFileInfo(info, [width]) → {string} #

Helper function to generate thumbnail wikicode

Parameters:

Name Type Attributes Description
info Object
Properties:
Name Type Description
imageInfo ImageModel
width number optional

Returns:

Type
string
Source:
Helper function to generate thumbnail wikicode