<?php
/**
 * @package WordPress
 * @subpackage Campoal
 */

global $campoal_options;
?>
<?php
$current_user       = wp_get_current_user();
$upload_dir         = wp_upload_dir();
$user_meta          = get_user_meta($current_user->ID);
$up_avatar_orginal  = get_user_meta($current_user->ID, 'avatar_orginal', true);
$up_avatar_id       = get_user_meta($current_user->ID, 'avatar_id', true);
$up_avatar          = conikal_get_avatar_url($current_user->ID, array('size' => 256), false);

$parse_avatar_url   = wp_parse_url($up_avatar, PHP_URL_SCHEME);
?>
<div class="<?php echo esc_attr($up_avatar ? '' : 'box-upload') ?>" id="box-upload">
    <div id="upload-container">
        <div id="aaiu-upload-container">
            <div id="aaiu-upload-imagelist"></div>
            <div id="imagelist">
                <?php if (!empty($up_avatar)) { ?>
                    <div class="ui fluid bordered rounded image">
                        <img src="<?php echo esc_url($parse_avatar_url ? $up_avatar : $upload_dir['baseurl'] . '/' . $up_avatar); ?>" file="<?php echo esc_attr($up_avatar) ?>" alt="<?php echo esc_attr($up_avatar) ?>" />
                        <label class="ui top right attached label deleteImage"><i class="right trash icon"></i>Delete</label>
                    </div>
                <?php } ?>
            </div>
            <div class="clearfix"></div>
            <div class="ui center aligned basic segment <?php echo esc_attr($up_avatar ? 'display none' : 'display block') ?>" id="upload-tool">
                <img src="<?php echo get_template_directory_uri() ?>/images/avatar-placeholder.svg" width="128" class="position-block-center">
                <div class="ui divider hidden"></div>
                <a href="javascript:void(0);" id="aaiu-uploader" class="ui basic button"><i class="folder outline open icon"></i><?php esc_html_e('Browse Images', 'campoal');?></a>
            </div>
            <input type="hidden" name="new_gallery" id="new_gallery" value="<?php echo esc_attr($up_avatar ? '~~~' . $up_avatar : '') ?>">
            <input type="hidden" id="new_attach" name="new_attach" value="<?php echo esc_attr($up_avatar_id ? $up_avatar_id : '') ?>">
        </div>
    </div>
</div>