hypejunction / cropper
Elgg 的 Cropper
1.1.0
2016-01-25 16:10 UTC
Requires
- php: >=5.5
- bower-asset/cropper: ~2.1
- composer/installers: ~1.0
README
为 Elgg 提供响应式图像裁剪输入
使用方法
将 cropper 添加为表单输入
echo elgg_view('input/cropper', array( 'src' => 'http://example.com/uri/image.jpg', 'ratio' => 16/9, 'name' => 'crop_coords', ));
将 cropper 添加到文件输入(基本用法)
// in your form echo elgg_view('input/file', array( 'name' => 'avatar', 'use_cropper' => true, )); // in your action $coords = get_input('crop_coords');
将 cropper 添加到文件输入(高级用法)
// in your form echo elgg_view('input/file', array( 'name' => 'cover', 'use_cropper' => array( 'name' => 'cover_crop_coords', 'ratio' => 16/9, 'src' => '/uri/image.jpg', // previously uploaded file 'x1' => 100, 'y1' => 100, 'x2' => 260, 'y2' => 190, ), )); // in your action $coords = get_input('cover_crop_coords');
注意事项
- 在您的操作中,务必使用相同的图像源进行裁剪。如果您将主图像源传递到文件输入,则需要实现新文件上传和主图像的逻辑,因为裁剪坐标可能会改变,即使没有新文件上传。