Getting image size through template?

75 Views Asked by At

I have a template on my wiki that I use to put in image side by side with an image of a location. The issue that I am having is that if the image (which is often taken from a movie screenshot) has a different ratio (say it is a wide screen 16:9) then there is a bunch of white space above and below the image. Is there a way to either

  1. Set the Google Maps widget to obtain its height and width based off of the dimensions of the image being supplied or...
  2. Obtain the aspect ratio of the image? If I can get that, then I can run a series of "#if" statements to set the widgets height & width.

Basically, I would like the map and image to have the same height when displayed on the page. The code for the template is below. Thanks in advance.

{{{!}}style="border: 1px solid darkgray;"
{{!}}-
{{!}}{{#widget:Google Maps 
|height=270
|width=480
|lat={{{lat|}}}
|lng= {{{lng|}}}
|zoom={{{zoom|}}}
|}}
{{!}}|[[image:{{{image|}}}|none|480x270px]]}}
{{!}}-
{{!}}}
1

There are 1 best solutions below

0
On

There is an extension for this (that I haven't tried myself): ImageSizeInfoFunctions. It will give you two parser functions for your purpose (and will work until the day one of your users try to put a file that a not a picture in there...)