Tell us what you are trying to do?
I have been looking all over the internet for a solution to this issue. Here it is... when you have a site where you have users uploading images, you might want to set some kind of dimensions for the images that are being uploaded. For example, you want the feature imaged to be a square, so you can CSS it to be rounded and nice.
Unfortunately not all users are capable of cropping images themselves, therefore, we have to make it easier for them. By having a way for them to crop the image right after they select the image they want to upload. A great example is Facebook profile picture, when you upload an image, it lets you drag and crop the image where you want it.
I know Toolset Forms does not have such feature and I already have requested this feature. But I was wondering if there is a way to do it meanwhile.
I searched the internet and found out that there are html5 image editing scripts, JQuery imaging editing, etc. I'm not sure if it's even possible to combine Toolset's Form with a JQuery image editing software.
I found this one that could do the job: hidden link
It's JQuery but I'm not sure if it will do the job. So I followed the instructions by:
1) Putting the files in my theme's folder
2) Including the JQUERY code below in the Form (Formulario de Anuncio, id= )
jQuery(function($) {
$('#target').Jcrop({
onSelect: showCoords,
bgColor: 'black',
bgOpacity: .4,
setSelect: [ 100, 100, 50, 50 ],
aspectRatio: 1
});
});
3) Added the id="target" to cred field
[cred_field field="foto-perfil" force_type="field" class="form-control" output="bootstrap" id="target"]
Now for implementation using php, here is where I got stuck. Here is the link: hidden link
I'm not sure where to add this function or what to call it:
<?php
$targ_w = $targ_h = 150;
$jpeg_quality = 90;
$src = 'demo_files/flowers.jpg';
$img_r = imagecreatefromjpeg($src);
$dst_r = ImageCreateTrueColor( $targ_w, $targ_h );
imagecopyresampled($dst_r,$img_r,0,0,$_POST['x'],$_POST['y'],
$targ_w,$targ_h,$_POST['w'],$_POST['h']);
// Comment out the header() call
// header('Content-type: image/jpeg');
imagejpeg($dst_r, $output_filename, $jpeg_quality);
?>
Is the SRC correct? Shouldn't it be something else with Toolset?
It also mentions that I need gd extension. Not sure what or how to implement it.
I know I'm asking a lot and it is probably out of the scope of support but if you could help me out, or at least guide me to the right direction, I appreciate it!