美文网首页首页投稿(暂停使用,暂停投稿)PHP实战
adaptive-images的使用方法 php 服务器端 图片

adaptive-images的使用方法 php 服务器端 图片

作者: Eric__li | 来源:发表于2016-07-07 12:51 被阅读52次
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  对比数据

相关文章

网友评论

    本文标题:adaptive-images的使用方法 php 服务器端 图片

    本文链接:https://www.haomeiwen.com/subject/ankljttx.html