首頁 >後端開發 >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