Home that big picture really is a more headache problem
On the PC display is no problem, but to the phone will exceed the page a large section, if you do adaptive, the image will be forced compression
Helpless can only use the Wp_is_mobile () function to hide the picture on the phone, but this function seems to not work on the ipad
High-resolution devices, such as the ipad Air, are fine, but they can be disastrous on low-resolution devices such as the iPad2.
So I decided to write a code to solve the problem.
Judging the Code
I will use the Windows system of the device as a PC, after all, blog for Chinese users, most of the home devices still use the Windows system
The principle is to determine the user AGENT submitted by the browser
123456789101112131415161718192021222324 |
<?php//Get user AGENT$agent = strtolower($_server[' http_user_agent ']); //Analysis Data $is _pc = (strpos ( $agent , ' Windows NT ' Span class= "Crayon-sy" >) ? true : false; $is _iphone = (strpos ( $agent , ' iphone ' ? true : false; $is _ipad = (strpos ( $agent , ' ipad ' ? true : false; $is _android = (strpos($agent, ' Android ') ? true : false; //Output data if($is _pc){ echo "This is PC"; } if($is _iphone){ echo "This is the iphone"; } if($is _ipad){ echo "This is the ipad"; } if($is _android){ echo "This is Android"; } ?> |
How to use
You can replace the Echo statement with the one you want to output on each device.
If you do not need to set the device separately, remove the if code corresponding to it
Prohibit WP Super cache cache home
Since WP Super cache caches the home page
Cause the judgment code to fail, we must prohibit it from caching the home page
1. Enter Settings-wp Super Cache
2. Advanced options, find "accepted filenames and denied URIs" at the bottom
3. Check the homepage (is_home)
4, click the Save button, then select the top content options, click "Delete Cache" can
5, if necessary, enter the pre-cache option, click "Preload Cache Now"
Use PHP to determine iphone, IPad, Android, PC devices