sunny_mody
11 years agoAdvisor
Avatar upload - crop image to a set size
Hi,
I want the user to upload an avatar of his choice but he should not be able to crop it,
Like there will be a crop selector in dotted border which can be resized, can we disable its resizing.
Let user just move the square dotted area which we can set it from community style.
Can we disable the resize functionality while cropping avatar image?
Thanks,
Sunny
Hi sunny_mody - You can do this in a 2 step process.
First create a custom component that you will place on the upload avatar page
<!-- --> <@liaAddScript> (function($) { $(document).one("LITHIUM:updateCoordinates",function() { var image = $(".lia-image-cropper-source-container > .lia-quilt-column-alley-left > img"); var img = new Image(); function addAspectRatio() { image.data("Jcrop").setOptions({aspectRatio: 1}); } function addLater() { if (!image.data("Jcrop")) { window.setTimeout(addLater, 50); } else { addAspectRatio(); } } img.onload = addLater; img.src=image[0].src; }); })(LITHIUM.jQuery); </@liaAddScript>
Then, in the skin properties, set the avatar height and width to be the same:
size.pixel.avatar_profile_h = 125 size.pixel.avatar_profile_w = 125 size.pixel.avatar_message_h = 50 size.pixel.avatar_message_w = 50
You are now good to go!