Use Jcrop for cropping. see #9375

git-svn-id: https://develop.svn.wordpress.org/trunk@10846 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2009-03-27 16:45:55 +00:00
parent 38fb326258
commit d861062501
6 changed files with 1295 additions and 17 deletions

View File

@@ -79,7 +79,7 @@ class Custom_Image_Header {
if ( 1 == $step )
wp_enqueue_script('farbtastic');
elseif ( 2 == $step )
wp_enqueue_script('cropper');
wp_enqueue_script('jcrop');
}
/**
@@ -90,9 +90,10 @@ class Custom_Image_Header {
function css_includes() {
$step = $this->step();
if ( 1 == $step ) {
if ( 1 == $step )
wp_enqueue_style('farbtastic');
}
elseif ( 2 == $step )
wp_enqueue_style('jcrop');
}
/**
@@ -215,13 +216,13 @@ class Custom_Image_Header {
*/
function js_2() { ?>
<script type="text/javascript">
function onEndCrop( coords, dimensions ) {
jQuery( '#x1' ).val(coords.x1);
jQuery( '#y1' ).val(coords.y1);
function onEndCrop( coords ) {
jQuery( '#x1' ).val(coords.x);
jQuery( '#y1' ).val(coords.y);
jQuery( '#x2' ).val(coords.x2);
jQuery( '#y2' ).val(coords.y2);
jQuery( '#width' ).val(dimensions.width);
jQuery( '#height' ).val(dimensions.height);
jQuery( '#width' ).val(coords.w);
jQuery( '#height' ).val(coords.h);
}
// with a supplied ratio
@@ -240,14 +241,12 @@ class Custom_Image_Header {
yinit = xinit / ratio;
}
}
new Cropper.Img(
'upload',
{
ratioDim: { x: xinit, y: yinit },
displayOnInit: true,
onEndCrop: onEndCrop
}
)
$('#upload').Jcrop({
aspectRatio: ratio,
setSelect: [ 0, 0, xinit, yinit ],
onSelect: onEndCrop
});
});
</script>
<?php