
1.png

2.png
#使用的 CodeIgniter 框架
#对应网页需填写
#将文件解压后 adaptive-images.php 放在根目录
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>网页</title>
<script>document.cookie='resolution='+Math.max(screen.width,screen.height)+'; path=/';</script>//重要
</head>
<body>
</body>
</html>
#.htaccess隐藏路由的文件里需要添加 (根据需求,不要直接覆盖掉之前创建的文件)
#这部分是ci框架隐藏 index.php的写法
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
#注释部分重要代码(这部分就是图片处理相关的)
#<IfModule mod_rewrite.c>
# Options +FollowSymlinks
# RewriteEngine On
#
# # Adaptive-Images -----------------------------------------------------------------------------------
#
# # Add any directories you wish to omit from the Adaptive-Images process on a new line, as follows:
# # RewriteCond %{REQUEST_URI} !some-directory
# # RewriteCond %{REQUEST_URI} !another-directory
#
# RewriteCond %{REQUEST_URI} !assets
#
# # Send any GIF, JPG, or PNG request that IS NOT stored inside one of the above directories
# # to adaptive-images.php so we can select appropriately sized versions
# RewriteRule \.(?:jpe?g|gif|png)$ adaptive-images.php
#
# # END Adaptive-Images -------------------------------------------------------------------------------
#</IfModule>
这样配置下, 手机掉用网页的时候服务器就会根据手机的分辨率输出对应的图片, 客户端省流量
附带有对比图片顶部, firefox 对比数据
网友评论