3.3 :: External image

Adding an image to 'Hello World'


Lets add an image above our text using an <easyExternalImage> element.
  1.  <?xml version="1.0" encoding="UTF-8" ?>
  2.  <wapl xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://wapl.wapple.net/wapl.xsd">
  3.   <layout>
  4.   <easyExternalImage filetype="png" scale="50">
  5.   <url>http://wapl.info/img/logo.png</url>
  6.   </easyExternalImage>
  7.   <easyChars>
  8.   <value>Hello World</value>
  9.   </easyChars>
  10.   </layout>
  11.  </wapl>
Downloadlisting 3.3.a

Our image is part of our layout so it is a child of the <layout> element.
..snip..
  1.   <layout>
  2.   <easyExternalImage filetype="png" scale="50">
  3.   <url>http://wapl.info/img/logo.png</url>
  4.   </easyExternalImage>
  5.   <easyChars>
  6.   <value>Hello World</value>
  7.   </easyChars>
  8.   </layout>
..snip..

easyExternalImage element


There are several different types of image you can add. Right now we are using an <easyExternalImage>. This is a quick way to display an image but, like easyChars, it is a bit limited.
..snip..
  1.   <easyExternalImage filetype="png" scale="50">
  2.   <url>http://wapl.info/img/logo.png</url>
  3.   </easyExternalImage>
..snip..

As it's an 'external' image it calls an image that is accessible by HTTP - so we don't have to worry much about relative paths right now.
<url> is a child element of <easyExternalImage>. It contains an absolute url to the desired image file.
..snip..
  1.   <url>http://wapl.info/img/logo.png</url>
..snip..

easyExternalImage attributes


This element has some attributes that you should be aware of.
Our example easyExternalImage has two attributes: 'filetype' and 'scale'.
Attributes are included according to XML specification: attributeName="attributeValue".
..snip..
  1.   <easyExternalImage filetype="png" scale="50">
..snip..

Get filetype right


If you're loading a .gif file, say so! Same goes for .jpg and .png files. Here, we are calling a .png file so we set the filetype attribute as 'png'.

Scaling by screen size


Different mobile browsers have different screen sizes and screen resolutions.
The scale value is a percentage of screen width.
A scale of 50 will make the image half the screen width of any mobile browser, as it is 50%.

Contents