Image Resize Filter 试用笔记

FileField Insert试用笔记中我讲到Image Resize Filter 模块,接下来我再以更多的例子和大家分享Image Resize Filter 模块的使用

Image Resize Filter 模块 需要 PHP 5 以上 的版本,安装之前请确认自己的服务器php的版本哦

安装:
解压后复制到sites/all/modules,然后到模块中启用

Image Resize Filter 模块属于过滤器,我们需要到“输入格式”(URL:admin/settings/filters),以“Filtered HTML”为例,点击“配置”(URL:admin/settings/filters/1)

在“过滤器”中找到 Image resize filter 并选中它,然后保存

2009-06-26_011106

保存后会退到“输入格式”(URL:admin/settings/filters)比较烦人,呵呵。继续重复点击“配置”(URL:admin/settings/filters/1),然后点击“设置"

2009-06-26_011659

允许使用的HTML标签: 增加 "<img>" 标签,如上图

在 Image resize settings 选项中
Resize images stored:*下有2个选择

Locally
On remote servers

Locally是默认启用的,是指本地的意思
On remote servers是远程的图片

Link to the original:

如果启用,可以给生成指定大小的图片链接到最初大小的图片,如果你安装了lightbox2 或shadowbox还可以附加class和rel attribute

我没有安装 lightbox2 或shadowbox ,所以没有设置class和rel attribute

现在我们把在 Image resize settings 选项中的3个选框都选中保存。

Image Resize Filter 模块怎么使用?往下看吧

点击导航菜单的"创建内容"--"Page"(URL:node/add/page)

标题:随便填
然后我们为了测试,需要上传一张图片,我用的示例图片:img_1080.jpg 尺寸:1600x1067

图片上传后,得到的URL是/sites/default/files/img_1080.jpg

在文章内容中输入<img src="/sites/default/files/img_1080.jpg" width="360" />

2009-06-26_014646

确认你的输入格式是“Filtered HTML”,如果你用别的输入格式也可以,但是要做和到我前面讲的设置

保存,效果如下图:

2009-06-26_014608

到sites\default\files\resize目录下看,会生成img_1080-360x240.jpg文件

试一下远程图片,我拿http://www.google.cn/intl/zh-CN/images/logo_cn.gif 举例,尺寸:276x100

编辑刚才的文章,在内容中加入<img src="http://www.google.cn/intl/zh-CN/images/logo_cn.gif” width="180" />

2009-06-30_023729

保存后,效果如下图。

2009-06-30_024312

Image Resize Filter 模块 会在 sites\default\files\resize目录下建立 remote 目录,调整大小后的图片的文件名为:md5后-宽度x高度.后缀名

由于之前我们在“输入格式”中启用了Link to the original:  Image Resize Filter 模块会自动生成链接到原图URL,但你发现没有,在你编辑内容时我们输入的内容并没有改变。

那么当我们要删除这篇文章,这些生成的图片怎么处理它?

经过我测试:
sites\default\files\resize\img_1080-360x240.jpg 会被删除
而从远程获得生成图片不会被删除,也就是指sites\default\files\resize\remote目录下的文件不会被删除。

由于写这篇文章分了2次才写完,中间隔了好几天(大家可以从文中所用到的图片日期就可以看出),在今天写的时候思路没有之前清晰。如果有疑问欢迎大家共同交流。

由于blogger被无期限“和谐”,故将此文转了过来。
原文:http://playts.blogspot.com/2009/06/image-resize-filter.html
文中图片由http://picasaweb.google.com转到http://www.flickr.com

评论

发表新评论

此内容将保密,不会被其他人看见。
  • 自动将网址与电子邮件地址转变为链接。
  • 允许HTML标签:<a> <img> <em> <del> <strong> <cite> <code> <pre> <ul> <ol> <li> <dl> <dt> <dd> <h3> <h4> <h5> <h6>
  • 自动断行和分段。
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo]. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

更多关於格式化选项的信息

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.