Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-21-2012, 07:23 AM   PM User | #1
Wuteverx1972
New Coder

 
Join Date: Aug 2010
Posts: 53
Thanks: 6
Thanked 1 Time in 1 Post
Wuteverx1972 is an unknown quantity at this point
Jquery Crop tool using custom page on Wordpress

Hey everyone,
I'm creating a profile account login where a user can input all their information and upload a profile pic (with cropping features).

I'm currently using "PHP & jQuery image upload and crop v1.2"

Link to source:
http://www.webmotionuk.co.uk/php-jqu...-and-crop-v11/

I'm using wordpress and I have created a custom page to implement this feature.

After some minor adjustments I have gotten the tool working (for the most part).

I am able to upload a pic into the specified directory and select my area for cropping.

The issue comes when I try to save the new thumbnail after I have cropped the original image. I get a 404 error.

The reason I get this error is because my wordpress site is under a different directory than the root.

My wordpress is in a subdirectory like:
mysite.com/wordpress_site/


My jQuery script is located inside my custom_page_template.php for example:
mysite.com/wordpress_site/wp-content/themes/my_theme/custom_page_template.php

When I access the page of where my script is hosted, it will automatically create me a new directory "upload_pic" where my images will be uploaded.

The link to the images uploaded will look like:
mysite.com/upload_pic/resize_1234.jpg

Notice that the "upload_pic" is not in the wordpress directory. That's okay with me for now...


Issue #1 (Now Fixed)
Whenever I uploaded a image file, the output img src link would be:
mysite.com/my_custom_page/upload_pic/resize_1234.jpg

The actual link to the uploaded image:
mysite.com/upload_pic/resize_1234.jpg

I rewrote the script to go back one directory inorder for the image to appear.

The reason I mention this is because when it comes to cropping the image, the new cropped image wont save. I know this has to do with the directory of the image of where it is trying to store it at.

I believe is has a lot to do with variables $thumb_image_location and $large_image_location in the following script:

PHP Code:
if (isset($_POST["upload_thumbnail"]) && strlen($large_photo_exists)>0) {
    
//Get the new coordinates to crop the image.
    
$x1 $_POST["x1"];
    
$y1 $_POST["y1"];
    
$x2 $_POST["x2"];
    
$y2 $_POST["y2"];
    
$w $_POST["w"];
    
$h $_POST["h"];
    
//Scale the image to the thumb_width set above
    
$scale $thumb_width/$w;
    
$cropped resizeThumbnailImage($thumb_image_location$large_image_location,$w,$h,$x1,$y1,$scale);
    
//Reload the page again to view the thumbnail
    
header("location:".$_SERVER['REQUEST_URI']);
    exit();

Basically, I need to properly set the correct path to my images when uploading and cropping my image.

Without wordpress, the script works just fine. I am able to upload and crop. All my original image files and cropped files can be seen in the uploaded directory.

However, I want to implement this into wordpress but the issue with image path is giving a hard time. Any advice would be appreciated!

Please pm me if you want to see my live script. Thanks!
Wuteverx1972 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:26 PM.


Advertisement
Log in to turn off these ads.