Expand all

ImageModel

Represents information about a single image

Constructor

new ImageModel(title, name, size, width, height, mimeType, url, descriptionUrl, descriptionShortUrl, pageID, repo, uploadDateTime, anonymizedUploadDateTime, creationDateTime, description, source, author, authorCount, license, permission, attribution, deletionReason, latitude, longitude, restrictions) #

Parameters:

Name Type Description
title mw.Title
name string

Image name (e.g. title of the artwork) or human-readable file if there is no better title

size number

Filesize in bytes of the original image

width number

Width of the original image

height number

Height of the original image

mimeType string
url string

URL to the image itself (original version)

descriptionUrl string

URL to the image description page

descriptionShortUrl string

A short URL to the description page for the image, using curid=...

pageID string

pageId of the description page for the image

repo string

The repository this image belongs to

uploadDateTime string

The time and date the last upload occurred

anonymizedUploadDateTime string

Anonymized and EL-friendly version of uploadDateTime

creationDateTime string

The time and date the original upload occurred

description string
source string
author string
authorCount number
license License
permission string
attribution string

Custom attribution string that replaces credit line when set

deletionReason string
latitude number
longitude number
restrictions Array.<string>
Source:

Properties

anonymizedUploadDateTime #

Properties:

Name Type Description
anonymizedUploadDateTime string

The anonymized date and time of the last upload

Source:

attribution #

Properties:

Name Type Description
attribution string

custom attribution string set by uploader that replaces credit line

Source:

author #

Properties:

Name Type Description
author string

The author of the image - unsafe HTML sometimes goes here

Source:

authorCount #

Properties:

Name Type Description
authorCount number

The number of different authors of the image. This is guessed by the number of templates with author fields, so might be less than the number of actual authors.

Source:

creationDateTime #

Properties:

Name Type Description
creationDateTime string

The date and time that the image was created

Source:

deletionReason #

Properties:

Name Type Description
reason string | null

for pending deletion, null if image is not about to be deleted

Source:

description #

Properties:

Name Type Description
description string

The description from the file page - unsafe HTML sometimes goes here

Source:

descriptionShortUrl #

Properties:

Name Type Description
descriptionShortUrl string

A short URL to the description page for the image, using curid=...

Source:

descriptionUrl #

Properties:

Name Type Description
descriptionUrl string

The URL to the description page for the image

Source:

height #

Properties:

Name Type Description
height number

The height, in pixels, of the original image

Source:

latitude #

Properties:

Name Type Description
latitude number

The latitude of the place where the image was created

Source:

license #

Properties:

Name Type Description
license License

The license under which the image is distributed

Source:

longitude #

Properties:

Name Type Description
longitude number

The longitude of the place where the image was created

Source:

mimeType #

Properties:

Name Type Description
mimeType string

The MIME type of the original image

Source:

name #

Properties:

Name Type Description
name string

Image name (e.g. title of the artwork) or human-readable file if there is no better title

Source:

pageID #

Properties:

Name Type Description
pageId number

of the description page for the image

Source:

permission #

Properties:

Name Type Description
additional string

license conditions by the author (note that this is usually a big ugly HTML blob)

Source:

repo #

Properties:

Name Type Description
repo string

The name of the repository where this image is stored

Source:

restrictions #

Properties:

Name Type Description
restrictions Array.<string>

Any re-use restrictions for the image, eg trademarked

Source:

size #

Properties:

Name Type Description
size number

The filesize, in bytes, of the original image

Source:

source #

Properties:

Name Type Description
source string

The source for the image (could be an organization, e.g.) - unsafe HTML sometimes goes here

Source:

thumbUrls #

Properties:

Name Type Description
thumbUrls Object

An object indexed by image widths with URLs to appropriately sized thumbnails

Source:

title #

Properties:

Name Type Description
title mw.Title

The title of the image file

Source:

uploadDateTime #

Properties:

Name Type Description
uploadDateTime string

The date and time of the last upload

Source:

url #

Properties:

Name Type Description
url string

The URL to the original image

Source:

width #

Properties:

Name Type Description
width number

The width, in pixels, of the original image

Source:

Methods

addThumbUrl(width, url) #

Add a thumb URL

Parameters:

Name Type Description
width number
url string
Source:
Add a thumb URL

getThumbUrl(width) → {string|undefined} #

Get a thumb URL if we have it.

Parameters:

Name Type Description
width number

Returns:

Type
string | undefined
Source:
Get a thumb URL if we have it.

hasCoords() → {boolean} #

Check whether the image has geolocation data.

Returns:

Type
boolean
Source:
Check whether the image has geolocation data.

newFromImageInfo(title, imageInfo) → {ImageModel}static #

Constructs a new Image object out of an object containing

imageinfo data from an API response.

Parameters:

Name Type Description
title mw.Title
imageInfo Object

Returns:

Type
ImageModel
Source:

Constructs a new Image object out of an object containing

imageinfo data from an API response.

newLicenseFromImageInfo(extmeta) → {License|undefined}static #

Constructs a new License object out of an object containing imageinfo data from an API response.

Parameters:

Name Type Description
extmeta Object

the extmeta array of the imageinfo data

Returns:

Type
License | undefined
Source:

Constructs a new License object out of an object containing imageinfo data from an API response.

parseExtmeta(data, type) → {string|number|boolean|Array}static #

Reads and parses a value from the imageinfo API extmetadata field.

Parameters:

Name Type Description
data Array
type string

one of 'plaintext', 'string', 'float', 'boolean', 'list', 'datetime'

Returns:

value or undefined if it is missing

Type
string | number | boolean | Array
Source:
Reads and parses a value from the imageinfo API extmetadata field.