Extension:ImageSizeInfoFunctions

Category:Extensions without an imageCategory:Extensions without a compatibility policyCategory:GPL licensed extensions
MediaWiki extensions manual
ImageSizeInfoFunctions
Release status: stableCategory:Stable extensions
Implementation Parser function Category:Parser function extensions
Description Return image width and height in pixel
Author(s) Dario de Judicibus
Maintainer(s)
Latest version 1.1.1 (2016-01-05)
MediaWiki 1.25+Category:Extensions with manual MediaWiki version
License GNU General Public License 2.0 or later
Download Category:Extensions in GitLab version control
  • $wgMessagesDir
Category:All extensions

The ImageSizeInfoFunctions extension provides two parser functions returning width and height size of a given image, available in the wiki.

Its purpose is to make it easier to create a template for resizing an image in percentage instead of absolute size. This is useful for images gallery based on images of the same scale but different size.

Features

  • imageWidth (imgw) returns the image width in pixel.
  • imageHeight (imgh) returns the image height in pixel.

Installation

  • Download and place the file(s) in a directory called ImageSizeInfoFunctions in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'ImageSizeInfoFunctions' );
    
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Usage

As for all parser functions:

{{#imgw: [image name] }}
{{#imgh: [image name] }}

Example

This template is useful for scaling the given image by percentage or, as usual, by absolute size:

<includeonly>[[Image:{{{imagename}}}|{{ #if:{{#pos:{{{newwidth|100}}}|px}}|{{{newwidth|100}}}| {{#expr: ({{#imgw: {{{imagename}}} }} * {{{newwidth|100}}}) / 100 }}px }}|{{{caption|}}}]]</includeonly>

Thus, assuming that the template is called ScaleImage:

Scaling the image to 15%:

{{ScaleImage</nowiki>
|imagename=eland.png
|caption=Città di Eland
|newwidth=15<nowiki>
}}

Scaling the image to 80 pixel:

{{ScaleImage</nowiki>
|imagename=eland.png
|caption=Città di Eland
|newwidth=80px<nowiki>
}}

Version history

  • 0.0.1 - testing
  • 1.0.0 - first stable release
  • 1.0.1 - improvement suggested by G.Hagedorn in discussion page
  • 1.1.0 - Updated the extension to be compatible with 1.19+
  • 1.1.1 - Updated the extension to be compatible with 1.25+

Feedback

Use the discussion page for feedback, questions, feature requests and bug reports.

See also

Category:Image extensions
Category:All extensions Category:Extensions in GitLab version control Category:Extensions included in Fandom Category:Extensions included in wiki.gg Category:Extensions with manual MediaWiki version Category:Extensions without a compatibility policy Category:Extensions without an image Category:GPL licensed extensions Category:Image extensions Category:LocalisationCacheRecache extensions Category:ParserClearState extensions Category:ParserFirstCallInit extensions Category:Parser function extensions Category:Stable extensions