"image uploader"
Bootstrap 3.0.0 Snippet by evarevirus

<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <!DOCTYPE html><html class=''> <head><script src='//production-assets.codepen.io/assets/editor/live/console_runner-079c09a0e3b9ff743e39ee2d5637b9216b3545af0de366d4b9aad9dc87e26bfd.js'></script><script src='//production-assets.codepen.io/assets/editor/live/events_runner-73716630c22bbc8cff4bd0f07b135f00a0bdc5d14629260c3ec49e5606f98fdd.js'></script><script src='//production-assets.codepen.io/assets/editor/live/css_live_reload_init-2c0dc5167d60a5af3ee189d570b1835129687ea2a61bee3513dee3a50c115a77.js'></script><meta charset='UTF-8'><meta name="robots" content="noindex"><link rel="shortcut icon" type="image/x-icon" href="//production-assets.codepen.io/assets/favicon/favicon-8ea04875e70c4b0bb41da869e81236e54394d63638a1ef12fa558a4a835f1164.ico" /><link rel="mask-icon" type="" href="//production-assets.codepen.io/assets/favicon/logo-pin-f2d2b6d2c61838f7e76325261b7195c27224080bc099486ddd6dccb469b8e8e6.svg" color="#111" /><link rel="canonical" href="https://codepen.io/jasonhibbs/pen/vnkaz?limit=all&page=10&q=image" /> <link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css'><script src='https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js'></script><link rel='stylesheet prefetch' href='//netdna.bootstrapcdn.com/font-awesome/4.0.0/css/font-awesome.css'> <style class="cp-pen-styles">@import url(https://fonts.googleapis.com/css?family=Open+Sans); *, *:before, *:after { box-sizing: border-box; } body { background: #eee; font-family: "Open Sans", Helvetica, sans-serif; } .setting { background: #fff; margin: 0 auto 3px; padding: 12px; width: 300px; } .setting h2 { color: #999; font-size: 14px; font-weight: 400; margin: 0 0 6px; line-height: 24px; } .setting a[data-action] { cursor: pointer; color: #555; font-size: 14px; line-height: 24px; transition: color 0.2s; } .setting a[data-action] i { width: 1.25em; text-align: center; } .setting a[data-action]:hover { color: #f80; } .setting a[data-action].disabled { opacity: 0.35; cursor: default; } .setting a[data-action].disabled:hover { color: #555; } .image_picker .settings_wrap { overflow: hidden; position: relative; } .image_picker .settings_wrap .drop_target, .image_picker .settings_wrap .settings_actions { float: left; } .image_picker .settings_wrap .drop_target { margin-right: 18px; } .image_picker .settings_wrap .settings_actions { margin-top: 12px; } .settings_actions.vertical a { display: block; } .drop_target { position: relative; cursor: pointer; background: #e6e6e6; border-top: 1px solid #cccccc; border-radius: 4px; width: 72px; height: 72px; padding: 4px 6px 6px; transition: all 0.2s; } .drop_target input[type="file"] { visibility: hidden; } .drop_target:before { content: '\f0ee'; font-family: FontAwesome; position: absolute; display: block; width: 60px; line-height: 60px; text-align: center; font-size: 32px; color: rgba(0, 0, 0, 0.3); transition: color 0.2s; } .drop_target:hover, .drop_target.dropping { background: #f80; border-top-color: #cc6d00; } .drop_target:hover:before, .drop_target.dropping:before { color: rgba(0, 0, 0, 0.6); } .drop_target .image_preview { width: 100%; height: 100%; background: no-repeat center; background-size: contain; position: relative; z-index: 2; } .image_details { width: 192px; padding: 4px; background: #e6e6e6; border-radius: 4px; position: absolute; top: 0; left: 84px; z-index: 5; opacity: 0; pointer-events: none; transition: opacity 0.4s; } .dropped ~ .image_details { opacity: 1; pointer-events: all; } .image_details:before { content: ''; display: block; width: 0; height: 0; border: 6px solid transparent; border-right-color: #e6e6e6; position: absolute; left: -12px; top: 10px; } .image_details .input_line { display: block; overflow: hidden; margin-bottom: 4px; } .image_details .input_line:last-of-type { margin-bottom: 0; } .image_details .input_line span, .image_details .input_line input { float: left; line-height: 24px; } .image_details .input_line span { font-size: 12px; color: #666; width: 20%; } .image_details .input_line input[type="text"] { width: 100%; color: #444444; appearance: none; border: 1px solid #e6e6e6; border-radius: 3px; background: #fff; height: 24px; line-height: 18px; padding: 3px 5px; font-size: 14px; transition: border 0.2s; } .image_details .input_line input[type="text"]:hover, .image_details .input_line input[type="text"]:focus { outline: 0; border: 1px solid #f80; } .image_details .input_line input[type="text"]::-webkit-input-placeholder { font-size: 14px; color: #999; } .image_details a.confirm { position: absolute; right: -12px; top: 50%; margin-top: -12px; display: block; width: 21px; height: 21px; border-radius: 100%; background: #eee; line-height: 23px; text-align: center; font-size: 16px; } body { overflow: hidden; } .setting:last-of-type { height: 1500px; } </style></head><body> <div class="setting"></div> <div class="setting image_picker"> <h2>Image</h2> <div class="settings_wrap"> <label class="drop_target"> <div class="image_preview"></div> <input id="inputFile" type="file"/> </label> <div class="settings_actions vertical"><a data-action="choose_from_uploaded"><i class="fa fa-picture-o"></i> Choose from Uploads</a><a class="disabled" data-action="remove_current_image"><i class="fa fa-ban"></i> Remove Current Image</a></div> <div class="image_details"> <label class="input_line image_title"> <input type="text" placeholder="Title"/> </label> <!--label.input_line.image_alt//input(type='text' placeholder='Alternative Text') --> <!--a.confirm(data-action='confirm_image_details')//i.fa.fa-check-circle --> </div> </div> </div> <div class="setting"></div> <script src='//production-assets.codepen.io/assets/common/stopExecutionOnTimeout-b2a7b3fe212eaa732349046d8416e00a9dec26eb7fd347590fbced3ab38af52e.js'></script><script src='//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script >var $dropzone = $('.image_picker'), $droptarget = $('.drop_target'), $dropinput = $('#inputFile'), $dropimg = $('.image_preview'), $remover = $('[data-action="remove_current_image"]'); $dropzone.on('dragover', function() { $droptarget.addClass('dropping'); return false; }); $dropzone.on('dragend dragleave', function() { $droptarget.removeClass('dropping'); return false; }); $dropzone.on('drop', function(e) { $droptarget.removeClass('dropping'); $droptarget.addClass('dropped'); $remover.removeClass('disabled'); e.preventDefault(); var file = e.originalEvent.dataTransfer.files[0], reader = new FileReader(); reader.onload = function(event) { $dropimg.css('background-image', 'url(' + event.target.result + ')'); }; console.log(file); reader.readAsDataURL(file); return false; }); $dropinput.change(function(e) { $droptarget.addClass('dropped'); $remover.removeClass('disabled'); $('.image_title input').val(''); var file = $dropinput.get(0).files[0], reader = new FileReader(); reader.onload = function(event) { $dropimg.css('background-image', 'url(' + event.target.result + ')'); } reader.readAsDataURL(file); }); $remover.on('click', function() { $dropimg.css('background-image', ''); $droptarget.removeClass('dropped'); $remover.addClass('disabled'); $('.image_title input').val(''); }); $('.image_title input').blur(function() { if ($(this).val() != '') { $droptarget.removeClass('dropped'); } }); //# sourceURL=pen.js </script> </body></html>

Related: See More


Questions / Comments: