Bug Fix – Image Field uploads would not work properlly so i had to fix
-
Thanks for this great plugin. It’s practically a staple of my wordpress development ??
Just wanted to let you know I fixed a bug I found and was wondering if you might want to take a look at it. Essentially for some reason, when I tried to upload using an image field within one of my meta boxes, if i had an image within my post content, the image field upload wouldn’t work. After doing some tests and such, I found that the image field was uploading an image properly to the website and to the right location, however verve wouldnt save the new image into the post meta.
I found that this was happening because verves verve_save_postdata function was running twice, and the second time it ran, the delete_post_meta($post_id, $key) ran after the file was uploaded.
The problem was hard to find but easy to solve.
At the begining of the verve_save_postdata function I did the following to ensure the function only runs once.
$saved = false; // used to ensure this function only runs once per
save ?? the other checks don’t work totallyfunction verve_save_postdata( $post_id, $post ) {
global $saved;
if($saved){ return; }
$saved = true; // all subsequent calls will not run
I’m not sure if this technique has introduced any bugs but it seems to have worked fine for my clients website.
I also added the ability to delete previously uploaded files so they don’t hang around on the system if you want the snippet just let me know. I’ve always wondered whether verve removed previous images uploaded via an image upload field.
- The topic ‘Bug Fix – Image Field uploads would not work properlly so i had to fix’ is closed to new replies.