Device Image

From Tera-WURFL

(Difference between revisions)
Jump to: navigation, search
(Downloading the Images)
(Downloading the Images)
Line 4: Line 4:
=== Downloading the Images ===
=== Downloading the Images ===
The current collection of device images is available from the [https://sourceforge.net/projects/wurfl/files/WURFL%20Device%20Images/ WURFL Project].
The current collection of device images is available from the [https://sourceforge.net/projects/wurfl/files/WURFL%20Device%20Images/ WURFL Project].
-
Once the images archive is downloaded, unzip them to a location that is available from the Internet.  Normally they are located in a folder called '''device_pix'''.
+
Once the images archive is downloaded, unzip it to a location that is available from the Internet.  Normally they are located in a folder called '''device_pix'''.
=== Detecting the Device Image ===
=== Detecting the Device Image ===

Revision as of 00:15, 3 June 2010

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. Once the images archive is downloaded, unzip it to a location that is available from the Internet. Normally they are located in a folder called device_pix.

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