跳转到主要内容
moxihang 提交于 15 August 2016

image_crop_widget.png

ImageWidgetCrop 模块使用

该模块提供图片字段的截取方法,让用户在上传图片的时候截取图片。

模块特点:设置截取类型,让用户按截取类型选择图片的截取范围

缺点:只能按固定的截取类型选择截取范围,不能让用户完全自由截取图片的大小和范围

例子

模块提供子模块"ImageWidgetCrop example",用于测试不同的截取效果

要求

  1. Crop API

安装过程

  1. 官方社区下载Crop API模块
  2. Github下载 ImageWidgetCrop 模块
  3. 安装 Crop API 和ImageWidgetCrop 模块

更多有关图片截取模块的分析:

https://www.drupal.org/node/1179172

使用方法

  1. 创建截取类型
    • On admin/structure choose Crop types step_1.png
    • Click on + Add crop type step_2.png
    • Add Name, Description and Aspect Ratio for your crop type and click Save crop type step_3.png
  2. Create an Image Style
    • On admin/structure/config choose Image styles step_4.png
    • Click on + Add image style step_5.png
    • Add Image style name and click Create new style step_6.png
    • Choose Manual crop effect and click Add step_7.png
    • Choose your Crop Type, to apply your crop selection, and click Add effect step_8.png
  3. Create an Image field
    • On desired content type (i.e. Basic page), on admin/structure/types, click on Manage fields step_9.png
    • Click on + Add field step_10.png
    • Choose Image, add label and click Save and continue step_11.png
  4. In form display of your page, on admin/structure/types/manage/page/form-display, set the widget for your field to ImageWidgetCrop step_12.pngand 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. step_13.png
  5. On Manage display of your page, on admin/structure/types/manage/page/display, set the display formatter Image step_14.pngand choose your image style and click Update and then Save step_15.png
  6. Add an image with your widget to your content and crop your picture, by crop types used for this image step_16.pngstep_17.png
标签
Drupal 版本