Page MenuHomePhabricator

Return aspect ratio of an image
Open, LowPublic

Description

Author: taylornate

Description:
It is common to use the multiple image template (http://en.wikipedia.org/wiki/Template:Multiple_image) to post post a row of thumbnails specified to be the same height. The template needs to know the width of each thumbnail in order to draw a box around them. It has no way to obtain the dimensions or aspect ratio of the original images. Therefore the template does not accept height as a parameter. In order to obtain the desired result, one must manually enter the dimensions of each image and desired height into a formula that returns the width.

Example:
Instead of entering simply this:
height = 100

One must enter this:
width1 = {{#expr: (100 * 750 / 536) round 0}}
width2 = {{#expr: (100 * 320 / 438) round 0}}
width3 = {{#expr: (100 * 892 / 723) round 0}}
etc.

This is hackish and cumbersome and can mess up formatting if an image is updated with a different aspect ratio. If there was a way to obtain the dimensions or aspect ratio of an image then the template could handle this.


Version: unspecified
Severity: enhancement

Details

Reference
bz30282

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 11:57 PM
bzimport added a project: MediaWiki-General.
bzimport set Reference to bz30282.
bzimport added a subscriber: Unknown Object (MLST).
bzimport created this task.Aug 9 2011, 5:03 AM
brion added a comment.Aug 15 2011, 6:39 PM

This template seems to be trying to reproduce the <gallery> tag hook.

Does it have specific features that are useful etc, or should it simply be replaced with use of <gallery>?

What exactly does it need to know image width/height for to draw boxes? Shouldn't it leave boxes to the style sheets or MediaWiki's own image box rendering?

As an aside, there are several extensions that do this - [[mw:Extension:MediaFunctions]], among others.

taylornate wrote:

Brion Vibber: This template formats the images in a much more aesthetically pleasing and efficient way.

Bawolff: This looks like just what I'm looking for. How might I ask for this to be included in a main release of MediaWiki or installed on Wikimedia so it can be used in the multiple image template on Wikipedia?

Bawolff: This looks like just what I'm looking for. How might I ask for this
to be included in a main release of MediaWiki or installed on Wikimedia so it
can be used in the multiple image template on Wikipedia?

Generally you need to get community consensus and then convince a senior dev to review it (generally takes a long time, especially if the use-cases for it aren't particularly strong. There's a long list of extensions waiting review at [[mw:Review_queue#Extensions]] )

https://gerrit.wikimedia.org/r/136274 makes file page count, width and height available to wiki pages via the Scribunto extension.

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 23 2015, 11:28 PM

https://gerrit.wikimedia.org/r/136274 makes file page count, width and height available to wiki pages via the Scribunto extension.

For clarification, that change was merged a while ago, so this is already possible.