Extension:ImageSizeInfoFunctions

From MediaWiki.org

Jump to: navigation, search

         

Manual on MediaWiki Extensions
List of MediaWiki Extensions
Crystal Clear action run.png
ImageSizeInfoFunctions

Release status: stable

Implementation  Parser function
Description return image width and height in pixel
Author(s)  Dario de Judicibus, (mantainer Giuseppe Briotti)
Last Version  1.0.1 (2009-01-24)
MediaWiki  1.8, 1.9, 1.10
License No license specified
Download ImageSizeInfoFunctions.php

check usage (experimental)

Contents

[edit] Introduction

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.

[edit] Features

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

[edit] Installation

  1. Download ImageSizeInfoFunctions.php
  2. Download ImageSizeInfoFunctions.i18n.php
  3. Save both files in the new extensions/ImageSizeInfoFunctions directory of your wiki.
  4. Insert these lines in the LocalSettings.php file:
// Activate ImageSizeInfoFunctions extension
include_once('extensions/ImageSizeInfoFunctions/ImageSizeInfoFunctions.php');

[edit] Configuration

no configuration required

[edit] Usage

As for all parser functions:

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

[edit] Template 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
|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
}}


[edit] Version history

  • 0.0.1 - testing
  • 1.0.0 - first stable release
  • 1.0.1 - improvement suggested by G.Hagedorn in discussion page

[edit] Alternatives

[edit] Feedback

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

[edit] Sites using this extension