ijaboCropTool.js
================
This jQuery plugin will help you to crop images in a certain applications. You can use this plugin on the user profile page where user can use this for cropping and update profile picture or avatar. You can also use this as image resizer tool on your dashboard.
!['ijaboCropTool'](img/ijaboCropTool.PNG)
## No documentation yet!
(feel free to write a bit about it)
## Download
Get the latest [ijaboCropTool](https://github.com/Mbere250/ijaboCropTool) plugin on [GitHub](https://github.com/) repository page.
## Dependencies
This plugin will works if is combined with the following dependency:
- [jQuery Library](https://jquery.com/)
## Customization
| Option | Description | Usage |
|----------------|--------------------|-------------------|
|preview|Cropped image should be displayed on a given image tags presented by class name. Just give the same class name to the image tags you need the cropped image displayed to. You can use many images with the same class name.'| preview:`'.image-class'` |
|setRatio| This is the ratio of cropped image. by default, the ratio is `1`, but you can define your own ratio. | setRatio:`1` setRatio:`0.5` setRatio:`8` setRatio:`7/8`|
|allowedExtensions| Only image extensions allowed. By default, allowed extensions are **JPG**, **JPEG**, and **PNG**. | allowedExtensions:`['jpg','png','jpeg']` |
|buttonsText| You can change action buttons text. By default The action button has **CROP** where Cancel button has **CANCEL** text.| buttonsText:`['CROP','QUIT']` |
|buttonsColor| You can customize buttons background color. Only hex code allowed. |buttonsColor:`['#30bf7d','#ee5155', -15]`|
|processUrl| This is very important option. Here you will define the process url. This should applied on core [PHP](http://php.net) projects, [Laravel](http://laravel.com) projects, [CodeIgniter](http://codeigniter.com) Projects and Other frameworks. | processUrl:`'path/to/process.php'`|
|withCSRF| Sometimes you have to add CSRF to every request. So, this plugin will allows you to do that. Just pass csrf name and hash in array if CSRF Security is enabled on your application |withCSRF:`['csrf_token','csrf_hash']` |
|fileName| You can define your own file name throught this option. Just make sure this name is similar to the file name at server side. |fileName:`'file_name'`|
## Callbacks
Sometimes you can run some tasks according to the results. Here you can see response at every process.
```JAVASCRIPT
onSuccess:function(message, element, status){
},
onError:function(message, element, status){
}
```
- **message** will be the feedback message after process.
- **element** is the selected input file.
- **status** is process response, this will give 1 if process done successfully and give 0 is process fail.
## How to use it?
# [1] - How to use this plugin in core [PHP](https://www.php.net/ 'Visit PHP Official website')
> Add This inside *head* tag
```html
<link rel="stylesheet" href="path/to/ijaboCropTool.min.css">
```
> Add this before closing *body* tag
```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="path/to/ijaboCropTool.min.js"></script>
```
> Add sample input file tag between *body* tag
```html
<input type="file" name="file" id="file">
```
> After all required scripts (JQuery and ijaboCropTool Plugin), you need to add the followings:
```html
<script>
$('#file').ijaboCropTool({
preview : '.image-previewer',
setRatio:1,
allowedExtensions: ['jpg', 'jpeg','png'],
buttonsText:['CROP','QUIT'],
buttonsColor:['#30bf7d','#ee5155', -15],
processUrl:'process/crop.php',
onSuccess:function(message, element, status){
alert(message);
},
onError:function(message, element, status){
alert(message);
}
});
</script>
```
> On server side
```php
<?php //crop.php file
$path = 'files/';
$file = $_FILES['file']['tmp_name'];
$new_image_name = 'UIMG'.date('Ymd').uniqid().'.jpg';
if(move_uploaded_file($file, $path.$image_name)){
echo json_encode(['status'=>1, 'msg'=>'success', 'name'=>$new_image_name]);
}else{
echo json_encode(['status'=>0, 'msg'=>'failed']);
}
?>
```
# [2] - How to use this plugin in [Laravel](https://laravel.com/ 'Visit Laravel Official website')
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects.
> Add This inside *head* tag
```html
<link rel="stylesheet" href="{{ asset('path/to/ijaboCropTool.min.css') }}">
```
> Add this before closing *body* tag
```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="{{ asset('path/to/ijaboCropTool.min.js') }}"></script>
```
> Add sample input file tag between *body* tag
```html
<input type="file" name="file" id="file">
```
> After all required scripts (JQuery and ijaboCropTool Plugin), you need to add the followings:
```html
<script>
$('#file').ijaboCropTool({
preview : '.image-previewer',
setRatio:1,
allowedExtensions: ['jpg', 'jpeg','png'],
buttonsText:['CROP','QUIT'],
buttonsColor:['#30bf7d','#ee5155', -15],
processUrl:'{{ route("crop") }}',
withCSRF:['_token','{{ csrf_token() }}'],
onSuccess:function(message, element, status){
alert(message);
},
onError:function(message, element, status){
alert(message);
}
});
</script>
```
>Route
```php
use App\Http\Controllers\UploadController;
Route::get('upload',[UploadController::class, 'index']);
Route::post('crop',[UploadController::class, 'crop'])->name('crop');
```
> On Server side.
```php
function crop(Request $request){
$path = 'files/';
$file = $request->file('file');
$new_image_name = 'UIMG'.date('Ymd').uniqid().'.jpg';
$upload = $file->move(public_path($path), $new_image_name);
if($upload){
return response()->json(['status'=>1, 'msg'=>'Image has been cropped successfully.', 'name'=>$new_image_name]);
}else{
return response()->json(['status'=>0, 'msg'=>'Something went wrong, try again later']);
}
}
```
# [3] - How to use this plugin in [CodeIgniter](https://www.codeigniter.com/ 'Visit CodeIgniter Official website')
CodeIgniter is a powerful PHP framework with a very small footprint, built for developers who need a simple and elegant toolkit to create full-featured web applications.
> Place this between head tags
```html
<link rel="stylesheet" href="<?= base_url('path/to/ijaboCropTool.min.css') ?>">
```
> Place this before closing body tag
```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="<?= base_url('path/to/ijaboCropTool.min.js') ?>"></script>
```
> Add a sample input file tag inside body tag.
```html
<input type="file" name="file" id="file">
```
> After all required scripts (JQuery and ijaboCropTool Plugin), you need to add the followings:
```html
<script>
$('#file').ijaboCropTool({
preview : '.image-previewer',
setRatio:1,
allowedExtensions: ['jpg', 'jpeg','png'],
processUrl:'<?= site_url('upload/process') ?>',
withCSRF:['<?= csrf_token() ?>','<?= csrf_hash() ?>'],
onSuccess:function(message, element, status){
alert(message);
},
onError:function(message, element, status){
alert(message);
}
});
</script>
```
> On Server side, you will need to create
没有合适的资源?快使用搜索试试~ 我知道了~
一个 jquery 插件,可用于裁剪图像_Javascript_代码_下载
共5个文件
js:2个
css:1个
md:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 77 浏览量
2022-06-15
20:36:05
上传
评论
收藏 280KB ZIP 举报
温馨提示
这个 jQuery 插件将帮助您在某些应用程序中裁剪图像。您可以在用户个人资料页面上使用此插件,用户可以使用它来裁剪和更新个人资料图片或头像。您还可以将其用作仪表板上的图像缩放工具。
资源推荐
资源详情
资源评论
收起资源包目录
ijaboCropTool-master.zip (5个子文件)
ijaboCropTool-master
img
ijaboCropTool.PNG 232KB
readme.md 11KB
jquery-1.7.1.min.js 92KB
ijaboCropTool.min.js 48KB
ijaboCropTool.min.css 5KB
共 5 条
- 1
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9157
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功