首页 >后端开发 >php教程 >Adaptive Images PHP图片适配类

Adaptive Images PHP图片适配类

WBOY
WBOY原创
2016-06-20 13:02:031214浏览

Adaptive Images是一个PHP编写的工具,它可将图像传输到小型移动设备上。应用嵌入式解决方案会根据设备屏幕大小 自动创建、捕捉、传输图片,而不需要额外改动图像。

使用方法

一、在图片文件夹创建.htaccess文件

<IfModule mod_rewrite.c><br /> Options +FollowSymlinks<br /> RewriteEngine On<br /> # Adaptive-Images -----------------------------------------------------------------------------------<br /> # Add any directories you wish to omit from the Adaptive-Images process on a new line, as follows:<br /> # RewriteCond %{REQUEST_URI} !ignore-this-directory<br /> # RewriteCond %{REQUEST_URI} !and-ignore-this-directory-too<br /> RewriteCond %{REQUEST_URI} !assets<br /> # Send any GIF, JPG, or PNG request that IS NOT stored inside one of the above directories<br /> # to adaptive-images.php so we can select appropriately sized versions<br /> RewriteRule .(?:jpe?g|gif|png)$ adaptive-images.php<br /> # END Adaptive-Images -------------------------------------------------------------------------------<br /></IfModule>

二、将如下JS脚本复制到每个需要自适应图片的网页的头部

<script>document.cookie='resolution='+Math.max(screen.width,screen.height)+'; path=/';</script>

三、HTML代码





test

<script>document.cookie='resolution='+Math.max(screen.width,screen.height)+'; path=/';</script>



Example in action





项目地址:http://adaptive-images.com/


声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn