How do I use the WP image functions in a page template?
Sorry for the long title, but my goal is very specific.
I know wp includes support for plupload, jcrop and the php gd library, but I’m running into dead-ends trying to implement some of that functionality on a custom page that will allow visitors to my website to do the following:
1. drag and drop an image to a target drop zone
2. crop that image and have the cropped preview show up on that page
3. allow them to redo the above if they don’t like it
4. save the cropped image as the thumbnail for a post.
The overall purpose of the page template is a form to allow the visitor to fill in key information to create a draft. I have the guts of the wp create post with thumbnail part working, but the image editing part is stuck. The approach I’ve tried so far is simply using the raw abilities of plupload, jcrop and gd on the front end (page template/form). I can make most of that work in bits and pieces following the examples and snippets they give, but the latest snag was the gd function imagejpeg displays raw data even though I used a call like this:
. . imagecopyresampled( $dst_image , $src_image , $dst_x , $dst_y , $src_x , $src_y , $dst_w , $dst_h , $src_w , $src_h ); . . . imagejpeg($dst_image,$img_file,$jpeg_quality);
I thought it was supposed to “save” the cropped file. Needless to say I’m frustrated and thinking there MUST be an easier way!
I am aware of plugins (and the amazing built in media stuff with version 3.5) that do this on the admin side, so can anyone throw me a hint (or a couple of examples) on how to leverage those function from the front end? WordPress has being doing this for years, but I can’t figure out how to get at that gold mine of mature code.
I will re-post this on stackoverflow. Thanks all!
- The topic ‘How do I use the WP image functions in a page template?’ is closed to new replies.