I need a way to change the encoding type for my comment form, without hacking the core files.

I'm aware of the function to work on the post editing form: post_edit_form_tag.

I've tried this:


But it doesn't work, the only next step I know of is to hack the source code... Any help would be very much appreciated—thanks in advance!

  • How is this not working? Any errors, warnings, strange behavior? The ID is correct? And it is an ID (and not a class)?
    – tfrommen
    Commented Mar 11, 2013 at 14:58
  • @t f, It's just not doing anything, I'm using an id and it is correct...
    – Circle B
    Commented Mar 11, 2013 at 16:50
  • Posting answers as comments just results in cluttered comment threads... Commented Mar 12, 2013 at 19:36

2 Answers 2


One Trick Pony answered the question, here's his solution:

jQuery('#comment_form')[0].encoding = 'multipart/form-data';

And here's a jsFiddle of it.


The ID in the form tag can vary in some themes. Instead, you can handle the process by adding a custom ID.

function custom_comment_form_id($comment_form)
        $existing_control = isset($comment_form['class_form']) ? $comment_form['class_form'] : ""; 
        $comment_form['class_form'] = trim($existing_control . ' vono_image_attr_id');
    return $comment_form;
add_filter('comment_form_defaults', 'custom_comment_form_id');

Afterwards, add the generated custom ID to the jQuery code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.