thinkphp 实现动态缩略图方案分享

浏览:1144 发布日期:2016/05/01 分类:技术分享 关键字: 动态缩略图

本文节选自 H5应用必须掌握的技能点-图片篇
http://www.imwinlion.com/archives/158
图片的服务器端自动缩略图

http://shang.qq.com/wpa/qunwpa?idkey=7322d7b39a8564d24b48b5e7d83fcde645f4c0e9ad84f1f7ddc7baff47574d7d

服务器端自动缩略图机制有很多,有应用自动缩略图,比如php我们可以选择 timthumb.php 。 点击下面下载

timthumb 如果不能下载 点击这里
http://www.imwinlion.com/archives/158

采用该机制需要注意 ,132 行左右

你需要把你的 域名添加到$ALLOWED_SITES 数组中,// If ALLOW_EXTERNAL is true and ALLOW_ALL_EXTERNAL_SITES is false, then external images will only be fetched from these domains and their subdomains.
if(! isset($ALLOWED_SITES)){
$ALLOWED_SITES = array (‘youhost.com’,’imwinlion.com’);
}


笔者采用的是另外一种。自建nginx 图片服务器,安装image_filter 模块server {
listen 80;
server_name img.imwinlion.com;
index index.html index.htm index.php;
root /alidata/mnt/imwinlion;
location ~ .*\.(php|php5)?$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ (.*)\.(gif|jpg|jpeg|png|PNG|JPG|JPEG)\!(\d+)x(\d+)$
{
try_files $1.$2 /empty last;
image_filter_interlace on;
image_filter_jpeg_quality 90;
image_filter resize $3 $4;
image_filter_buffer 3M;
}
location ~ .*\.(gif|jpg|JPG|PNG|GIF|BMP|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
access_log /dev/null;
}
最佳答案
评论( 相关
后面还有条评论,点击查看>>