Device Image

From Tera-WURFL

Revision as of 22:45, 2 June 2010 by Kamermans (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

As of Tera-WURFL 2.1.2, you can detect and display an image of the detected mobile device.

Getting Started with Device Images

Downloading the Images

The current collection of device images is available from the WURFL Project

Detecting the Device Image

The following code demonstrates the usage of the TeraWurflDeviceImage and displaying the image that is detected.

<?php
require_once 'TeraWurfl.php';
require_once 'TeraWurflUtils/TeraWurflDeviceImage.php';
$wurflObj = new TeraWurfl();
$wurflObj->getDeviceCapabilitiesFromAgent();
$image = new TeraWurflDeviceImage($wurflObj);
/**
 * The location of the device images as they are accessed on the Internet
 * (ex. '/device_pix/', 'http://www.mydomain.com/pictures/')
 * The filename of the image will be appended to this base URL
 */
$image->setBaseURL('/device_pix/');
/**
 * The location of the device images on the local filesystem
 */
$image->setImagesDirectory('/var/www/device_pix/');
/**
 * Get the source URL of the image (ex. '/device_pix/blackberry8310_ver1.gif')
 */
$image_src = $image->getImage();
if($image_src){
	// If and image exists, show it
	$image_html = sprintf('<img src="%s" border="0"/>',$image_src);
	echo $image_html;
}else{
	// If an image is not available, show a message
	echo "No image available";
}
?>
Personal tools
Namespaces
Variants
Actions
WURFL DBAPI
Toolbox