-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.js
More file actions
22 lines (19 loc) · 717 Bytes
/
main.js
File metadata and controls
22 lines (19 loc) · 717 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(function($){
$(window).load(function(){
$('.smartcrop').each(function(){
var t = $(this),
img = t.find('img'),
width = t.attr('data-width'),
height = t.attr('data-height');
SmartCrop.crop(img[0], {width: width, height: height}, function(result){
var crop = result.topCrop,
canvas = t.find('canvas')[0],
ctx = canvas.getContext('2d');
canvas.width = width;
canvas.height = height;
ctx.drawImage(img[0], crop.x, crop.y, crop.width, crop.height, 0, 0, canvas.width, canvas.height);
img.after(canvas).closest('.smartcrop').addClass('cropped');
});
});
});
})(jQuery)