Device Image

From Tera-WURFL

(Difference between revisions)
Jump to: navigation, search
(Detecting the Device Image)
m (Reverted edits by Lemon1314 (talk) to last revision by Kamermans)
 
Line 6: Line 6:
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'''.
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'''.
-
Studies show that just walking up two flights of stairs for a whole year will cause you to lose 50 pounds! http://lhasa-tour.blogcu.com/ Slimming Patch.Step 7: Lay off Of The Junk FoodWhile some junk food is ok to have,
+
=== Detecting the Device Image ===
-
Every lady's vanity would be their hair. Women spend so much money and time just to beautify this crown of theirs. http://lhasatour.multiply.com/ No doubt, hair is what makes women beautiful. Even you have a pretty face, or a sexy body,
+
The following code demonstrates the usage of the '''TeraWurflDeviceImage''' and displaying the image that is detected.
-
To solve this issue, we have Moroccan oil now. This product is nature's gift to mankind. http://lhasatours.blogfa.com/ This hair treatment is easily absorbed by the hair and leaves it silky and shiny.
+
<geshi lang=php lines=0><?php
-
Wash your hair first with shampoo and conditioner. Afterwards, http://shanghaitours.splinder.com/ 5 ml of it should be enough. Apply this on your hair first.  
+
require_once 'TeraWurfl.php';
-
This one distinguishes your curls vividly without that sticky feeling. http://dear-china-tour.weebly.com/ Treatment for a more glorious curl.Moroccan Oil Hydrating Styling Cream would suit best for people who have thick or curly hair.
+
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";
 +
}
 +
?></geshi>

Latest revision as of 03:02, 2 November 2011

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