Constructor
new GuessedThumbnailInfo()
#
Properties
displayableExtensions
#
File extensions which can be displayed in the browser. Other file types need to be thumbnailed even if the size of the original file would be right.
vectorExtensions
#
File extensions which are vector types (as opposed to bitmap). Thumbnails of vector types can be larger than the original file.
Methods
canBeDisplayedInBrowser(file) → {boolean}protected
#
True if the file type can be displayed in most browsers, false if it needs thumbnailing
Parameters:
| Name | Type | Description |
|---|---|---|
file |
mw.Title |
Returns:
- Type
- boolean
canHaveLargerThumbnailThanOriginal(file) → {boolean}protected
#
True if the file is of a type for which the thumbnail can be scaled beyond the original size.
Parameters:
| Name | Type | Description |
|---|---|---|
file |
mw.Title |
Returns:
- Type
- boolean
get(file, sampleUrl, width, originalWidth, originalHeight) → {jQuery.Promise.<Thumbnail>}
#
Try to guess the thumbnailinfo for a thumbnail without doing an API request. An existing thumbnail URL is required.
There is no guarantee this function will be successful - in some cases, it is impossible to guess how the URL would look. If that's the case, the promise just rejects.
Parameters:
| Name | Type | Description |
|---|---|---|
file |
mw.Title | |
sampleUrl |
string | a thumbnail URL for the same file (but with different size). |
width |
number | thumbnail width in pixels |
originalWidth |
number | width of original image in pixels |
originalHeight |
number | height of original image in pixels |
Returns:
- Type
- jQuery.Promise.<Thumbnail>
getUrl(file, sampleUrl, width, originalWidth) → {string|undefined}
#
undefined}
#
Try to guess the URL of a thumbnail without doing an API request. See #get().
Parameters:
| Name | Type | Description |
|---|---|---|
file |
mw.Title | |
sampleUrl |
string | a thumbnail URL for the same file (but with different size) |
width |
number | thumbnail width in pixels |
originalWidth |
number | width of original image in pixels |
Returns:
a thumbnail URL or nothing
- Type
-
string
|
undefined
guessFullUrl(file, thumbnailUrl) → {string}protected
#
Try to guess the original URL to the file, from a thumb URL.
Parameters:
| Name | Type | Description |
|---|---|---|
file |
mw.Title | |
thumbnailUrl |
string |
Returns:
URL of the original file
- Type
- string
guessHeight(file, width, originalWidth, originalHeight) → {number}protected
#
Guess what will be the height of the thumbnail, given its width.
Parameters:
| Name | Type | Description |
|---|---|---|
file |
mw.Title | |
width |
number | thumbnail width in pixels |
originalWidth |
number | width of original image in pixels |
originalHeight |
number | height of original image in pixels |
Returns:
guessed height
- Type
- number
guessThumbUrl(file, originalUrl, width) → {string|undefined}protected
#
undefined}protected
#
Hardest version: try to guess thumbnail URL from original
Parameters:
| Name | Type | Description |
|---|---|---|
file |
mw.Title | |
originalUrl |
string | URL for the original file |
width |
number | thumbnail width in pixels |
Returns:
thumbnail URL
- Type
-
string
|
undefined
guessWidth(file, width, originalWidth) → {number}protected
#
Guess what will be the width of the thumbnail. (Thumbnails for most file formats cannot be larger than the original file so this might be smaller than the requested width.)
Parameters:
| Name | Type | Description |
|---|---|---|
file |
mw.Title | |
width |
number | thumbnail width in pixels |
originalWidth |
number | width of original image in pixels |
Returns:
guessed width
- Type
- number
isFullSizeUrl(url, file) → {boolean}protected
#
Checks if a given thumbnail URL is full-size (the original image) or scaled
Parameters:
| Name | Type | Description |
|---|---|---|
url |
string | a thumbnail URL |
file |
mw.Title |
Returns:
- Type
- boolean
needsOriginal(file, width, originalWidth) → {boolean}protected
#
True if the original image needs to be used as a thumbnail.
Parameters:
| Name | Type | Description |
|---|---|---|
file |
mw.Title | |
width |
number | thumbnail width in pixels |
originalWidth |
number | width of original image in pixels |
Returns:
- Type
- boolean
obscureFilename(url, file) → {string}protected
#
Removes the filename in a reversible way. This is useful because the filename can be nearly anything and could cause false positives when looking for patterns.
Parameters:
| Name | Type | Description |
|---|---|---|
url |
string | a thumbnail URL |
file |
mw.Title |
Returns:
thumbnail URL with occurrences of the filename replaced by <filename>
- Type
- string
replaceSize(file, sampleUrl, width) → {string|undefined}protected
#
undefined}protected
#
Given a thumbnail URL with a wrong size, returns one with the right size.
Parameters:
| Name | Type | Description |
|---|---|---|
file |
mw.Title | |
sampleUrl |
string | a thumbnail URL for the same file (but with different size) |
width |
number | thumbnail width in pixels |
Returns:
thumbnail URL with the correct size
- Type
-
string
|
undefined