ImageWidgetCrop 模块使用
该模块提供图片字段的截取方法,让用户在上传图片的时候截取图片。
模块特点:设置截取类型,让用户按截取类型选择图片的截取范围
缺点:只能按固定的截取类型选择截取范围,不能让用户完全自由截取图片的大小和范围
例子
模块提供子模块"ImageWidgetCrop example",用于测试不同的截取效果
要求
安装过程
- 官方社区下载Crop API模块
- Github下载 ImageWidgetCrop 模块
- 安装 Crop API 和ImageWidgetCrop 模块
更多有关图片截取模块的分析:
https://www.drupal.org/node/1179172
使用方法
- 创建截取类型
- On
admin/structure
choose Crop types - Click on + Add crop type
- Add Name, Description and Aspect Ratio for your crop type and click Save crop type
- On
- Create an Image Style
- On
admin/structure/config
choose Image styles - Click on + Add image style
- Add Image style name and click Create new style
- Choose Manual crop effect and click Add
- Choose your Crop Type, to apply your crop selection, and click Add effect
- On
- Create an Image field
- On desired content type (i.e. Basic page), on
admin/structure/types
, click on Manage fields - Click on + Add field
- Choose Image, add label and click Save and continue
- On desired content type (i.e. Basic page), on
- In form display of your page, on
admin/structure/types/manage/page/form-display
, set the widget for your field to ImageWidgetCrop and select your crop types in the Crop settings list and click Update and then Save. You can configure the widget to create different crops on each crop types. For example, if you have an editorial site, you need to display an image on different places. With this option, you can set an optimal crop zone for each of the image styles applied to the image. - On Manage display of your page, on
admin/structure/types/manage/page/display
, set the display formatter Image and choose your image style and click Update and then Save - Add an image with your widget to your content and crop your picture, by crop types used for this image
标签
Drupal 版本