(function ($) {
    $.field_selectfolderpath = function (element, options) {
        var defaults = {
        }
        var plugin = this;
        plugin.settings = {}
        var $element = $(element), 
            element = element;
        plugin.init = function () {
            plugin.settings = $.extend({}, defaults, options);
            $element.find('.img-avatar').click(function (e) {
                $element.find('input[type="file"].upload').click();
            });
            $element.find('input[type="file"].upload').change(function () {
                plugin.readURL(this);
            });
        };
        plugin.readURL = function (input) {
            if (input.files && input.files[0]) {
                let reader = new FileReader();
                reader.onload = function (e) {
                    $element.find('.img-avatar').attr('src', e.target.result);
                }
                reader.readAsDataURL(input.files[0]);
            }
        }
        plugin.example_function = function () {
        };
        plugin.init();
    }
    
    $.fn.field_selectfolderpath = function (options) {
        
        return this.each(function () {
            
            if (undefined == $(this).data('field_selectfolderpath')) {
                var plugin = new $.field_selectfolderpath(this, options);
                $(this).data('field_selectfolderpath', plugin);
            }
        });
    }
})(jQuery);