Open main menu

Extension:ImageSizeInfoFunctions

MediaWiki extensions manual
OOjs UI icon advanced.svg
ImageSizeInfoFunctions
Release status: stable
Implementation Parser function
Description return image width and height in pixel
Author(s) Dario de Judicibus, (mantainer Giuseppe Briotti, Tim Aldridge)
Latest version 1.1.1 (2016-01-05)
MediaWiki 1.25+
License GPLv2.0+
Download GitHub
Translate the ImageSizeInfoFunctions extension if it is available at translatewiki.net
Check usage and version matrix.

Contents

IntroductionEdit

ImageSizeInfoFunctions is an extension to MediaWiki that gives 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.

FeaturesEdit

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

InstallationEdit

  • 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:
    wfLoadExtension( 'ImageSizeInfoFunctions' );
    
  •   Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

To users running MediaWiki 1.24 or earlier:

The instructions above describe the new way of installing this extension using wfLoadExtension() If you need to install this extension on these earlier versions (MediaWiki 1.24 and earlier), instead of wfLoadExtension( 'ImageSizeInfoFunctions' );, you need to use:

require_once "$IP/extensions/ImageSizeInfoFunctions/ImageSizeInfoFunctions.php";

ConfigurationEdit

no configuration required

UsageEdit

As for all parser functions:

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

Template ExampleEdit

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
|imagename=eland.png
|caption=Città di Eland
|newwidth=15
}}

Scaling the image to 80 pixel:


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

Version historyEdit

  • 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+

AlternativesEdit

FeedbackEdit

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

Sites using this extensionEdit