(function($){
    $('body').on('click', '.wkfe_ld_template_course_cover_photo_upload', function(e){
        e.preventDefault();

            var button = $(this),
                custom_uploader = wp.media({
            title: 'Insert image',
            library : {
                type : 'image'
            },
            button: {
                text: 'Use this image'
            },
            multiple: false
        }).on('select', function() {
            var attachment = custom_uploader.state().get('selection').first().toJSON();
            console.log(attachment);
            $(button).siblings('#wkfe-ld-template-course-cover-photo').val(attachment.url);
        })
        .open();
    });
})(jQuery);