I'm having trouble using Jcrop on responsive width images for the mobile version of a site.
When I apply a width setting of 100% to the uploaded image - to allow a user on a mobile device the best option of providing a successful crop, the outputted crop is not the crop area chosen.
This is due, I think, to jcrop working from the size of the true image, not the resized version (100% width), but I don't know how to fix it.
I have seen this question (and answer)but I don't understand how to apply to my Jcrop function:
$(function(){
$('#target').Jcrop({
aspectRatio: 4/3,
bgColor: '#000',
bgOpacity: .4,
onSelect: updateCoords
});
});
function updateCoords(c)
{
$('#x').val(c.x);
$('#y').val(c.y);
$('#w').val(c.w);
$('#h').val(c.h);
};
function checkCoords()
{
if (parseInt($('#w').val())) return true;
alert('Please select a crop region then press submit.');
return false;
};
This works beautifully if I don't apply any size CSS to the uploaded image, but as soon as I start trying to manage the images size for display, the cropped image is skewed.
I thought Google would have thrown up more results on this as i would expect it to be a common problem - or maybe I'm just too dim to see the obvious.
I hope someone can help.