ID, 'avatar_attachment_id', true); if ($attachment_id) { echo wp_get_attachment_image($attachment_id, 'thumbnail', false, array( 'style' => 'display:block;margin-top:10px;', 'class' => 'avatar-preview' )); echo '

'; } ?>
false)); if ($movefile && !isset($movefile['error'])) { $attachment_id = wp_insert_attachment(array( 'post_mime_type' => $movefile['type'], 'post_title' => preg_replace('/\.[^.]+$/', '', basename($movefile['file'])), 'post_status' => 'inherit' ), $movefile['file']); if (!is_wp_error($attachment_id)) { require_once(ABSPATH . 'wp-admin/includes/image.php'); wp_update_attachment_metadata($attachment_id, wp_generate_attachment_metadata($attachment_id, $movefile['file'])); update_user_meta($user_id, 'avatar_attachment_id', $attachment_id); } } } // Сохранение выбранного изображения из медиатеки if (!empty($_POST['avatar_attachment_id'])) { update_user_meta($user_id, 'avatar_attachment_id', intval($_POST['avatar_attachment_id'])); } }