Front End Image Upload
-
I am trying to upload profiles from the front end of my website. All information is making it through okay to the custom profile post I have made in the back end except I can’t get the image to store in the profile post. I am using inline upload plugin to upload image.
Front End Code:
update_post_meta($post_id, ‘vsip_custom_image’, $_POST[‘custom_image’]);
<?php echo do_shortcode(“[inline_upload uploadpath=’/uploads’]”); ?>
Back End Code: (in functions)
<?php
////////////////////////////////
// Register the Service Manager
////////////////////////////////
function p_register() {
//Arguments to create post type
$args = array(
‘label’ => __(‘Profiles’),
‘singular_label’ => __(‘Profile’),
‘public’ => true,
‘show_ui’ => true,
‘capability_type’ => ‘post’,
‘hierarchial’ => true,
‘has_archive’ => true,
‘supports’ => array(‘title’, ‘editor’, ‘thumbnail’),
‘rewrite’ => array(‘slug’ => ‘profile’),
//’post_type’ => ‘profile’);
register_post_type(‘profile’, $args);
}add_action(‘init’, ‘p_register’);
/* ——————————————————————— *
* Initialization
* ——————————————————————— */// Custom Meta Box
add_action( ‘add_meta_boxes’, ‘vsip_project_add_meta’);// Save Meta Data
add_action(‘save_post’, ‘vsip_post_save_data’);/* ——————————————————————— *
* Custom Project Meta Box
* ——————————————————————— */// Field Array
$prefix = ‘vsip_’;$vsip_post_meta_box = array(
‘id’ => ‘vsip-post-meta-box’,
‘title’ => __(‘Custom Meta’, ‘framework’),
‘page’ => ‘profile’,
‘context’ => ‘normal’,
‘priority’ => ‘high’,
‘fields’ => array(array(
‘label’ => ‘Image’,
‘name’ => ‘Image’,
‘id’ => $prefix.’custom_image’,
‘type’ => ‘image’
),// If Image
case ‘image’:echo ‘<tr style=”border-top:1px solid #eeeeee;”>’,
‘<th style=”width:25%”><label for=”‘, $field[‘id’], ‘”>‘, $field[‘name’], ‘<span style=” display:block; color:#999; line-height: 20px; margin:5px 0 0 0;”>’. $field[‘desc’].'</span></label></th>’,
‘<td>’;$image = get_template_directory_uri().’/img/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=”‘.$field[‘id’].'” type=”hidden” class=”custom_upload_image” value=”‘.$meta.'” />
<img src=”‘.$image.'” class=”custom_preview_image” alt=”” />
<input class=”custom_upload_image_button button” type=”button” value=”Choose Image” />
<small> Remove Image</small>
<br clear=”all” /><span class=”description”>’.$field[‘desc’].'</span>’;
break;
- The topic ‘Front End Image Upload’ is closed to new replies.