Page 1 of 1

Tera-WURFL Device Images (Device Thumbnails)

PostPosted: Wed Mar 24, 2010 2:57 am
by kamermans
Those of you that have used Tera-WURFL 1.x may remember that you used to be able to display an image of the visiting device, if one was available. When I created version 2.0, I decided not to include this functionality be default since the set of device images (maintained by the WURFL group) was not actively maintained. Additionally, I wanted to spend my time improving the detection code and adding more features that would appeal to the community as a whole.

I am proud to announce that the Device Images feature is back in version 2.1.2! It comes in the form of a utility class that you can use to retrieve the device image from an instance of Tera-WURFL.

Here's a usage example:
Code: Select all
$image = new TeraWurflDeviceImage($teraWurflObj);
$image->setBaseURL("http://www.yourdomain.com/device_pix/");
$image->setImagesDirectory("/var/www/html/device_pix/");
if($image->getImage()===false){
   // There was no device image available
   echo "No image available<br/>";
}else{
   // Display the image with it's name for the title
   $title = $teraWurflObj->capabilities['product_info']['brand_name'] . " " . $teraWurflObj->capabilities['product_info']['model_name'];
   echo sprintf('<img border="0" title="%s" src="%s" />',$title,$image);
}


The TeraWurflDeviceImage class is a major improvement from the old method of determining a device image; if it is not able to find an image for the exact device, it looks for an ancestor to the device and uses a picture of that device instead (this behavior is configurable via TeraWurflDeviceImage::descend).

You can download the device images from the WURFL Project's website: http://wurfl.sourceforge.net/utilities/ ... bnails.php