Saving custom meta for media upload
-
Hello,
I have currently added a custom meta field for uploading a media file (image). I can successfully add the upload button to display and work but I’m having problems saving the field when updating the page.
Code I’m using to create and display the field:
<?php $image = get_template_directory_uri().'/images/image.png'; echo '<span class="custom_default_image" style="display:none">'.$image.'</span>'; if ($meta) { $image = wp_get_attachment_image_src($meta, 'medium'); $image = $image[0]; } echo '<input name="image-upload-one" type="hidden" class="custom_upload_image" value="'.$meta.'" /> <img src="'.$image.'" class="custom_preview_image" alt="" /> <br /> <input class="custom_upload_image_button button" type="button" value="Choose Image" /> <br/> <small> <a href="#" class="custom_clear_image_button">Remove Image</a> </small> <br clear="all" /> <span class="description">'.$field['desc'].'</span>'; ?>The above code is from:
http://code.tutsplus.com/tutorials/reusable-custom-meta-boxes-part-3-extra-fields–wp-23821
I can’t find a way to save the input.I’ve created simple text fields/texttext area fields and can save them no problem using the follow in a save function:
if (isset($_POST['text-two'])) { update_post_meta($post_id,'textTwo', esc_attr($_POST['text-two'])); }Any ideas how I can save the image custom meta field?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Saving custom meta for media upload’ is closed to new replies.