Index: src/wp-includes/css/media-views.css
===================================================================
--- src/wp-includes/css/media-views.css	(revision 29372)
+++ src/wp-includes/css/media-views.css	(working copy)
@@ -700,7 +700,7 @@
  */
 .attachments {
 	margin: 0;
-	padding-right: 16px;
+	padding: 8px;
 	-webkit-overflow-scrolling: touch;
 }
 
@@ -710,9 +710,10 @@
 .attachment {
 	position: relative;
 	float: left;
-	padding: 0;
-	margin: 0 10px 20px;
+	padding: 8px;
+	margin: 0;
 	color: #464646;
+	cursor: pointer;
 	list-style: none;
 	text-align: center;
 	-webkit-user-select: none;
@@ -719,92 +720,62 @@
 	-moz-user-select: none;
 	-ms-user-select: none;
 	user-select: none;
+	width: 20%;
+	box-sizing: border-box;
 }
 
 .attachment:focus {
 	-webkit-box-shadow:
-		0 0 0 1px #5b9dd9,
-		0 0 2px 2px #5b9dd9;
+		inset 0 0 0 5px #fff,
+		inset 0 0 1px 7px #5b9dd9;
 	box-shadow:
-		0 0 0 1px #5b9dd9,
-		0 0 2px 2px #5b9dd9;
+		inset 0 0 0 5px #fff,
+		inset 0 0 1px 7px #5b9dd9;
 	outline: none;
 }
 
 .selected.attachment {
 	-webkit-box-shadow:
-		0 0 0 1px #fff,
-		0 0 0 3px #ccc;
+		inset 0 0 0 5px #fff,
+		inset 0 0 0 7px #ccc;
 	box-shadow:
-		0 0 0 1px #fff,
-		0 0 0 3px #ccc;
+		inset 0 0 0 5px #fff,
+		inset 0 0 0 7px #ccc;
 }
 
-.selected.attachment:focus {
-	-webkit-box-shadow:
-		0 0 0 1px #fff,
-		0 0 0 5px #1e8cbe;
-	box-shadow:
-		0 0 0 1px #fff,
-		0 0 0 5px #1e8cbe;
-}
-
 .attachment-preview {
 	position: relative;
-	width: 199px;
-	height: 199px;
-	-webkit-box-shadow:
-		inset 0 0 15px rgba( 0, 0, 0, 0.1 ),
-		inset 0 0 0 1px rgba( 0, 0, 0, 0.05 );
-	box-shadow:
-		inset 0 0 15px rgba( 0, 0, 0, 0.1 ),
-		inset 0 0 0 1px rgba( 0, 0, 0, 0.05 );
-	background: #eee;
-	cursor: pointer;
 }
 
+.attachment-preview:before {
+	content: '';
+	display: block;
+	padding-top: 100%;
+}
+
 .attachment .icon {
 	margin: 0 auto;
 	overflow: hidden;
-	padding-top: 20%;
 }
 
 .attachment .thumbnail {
-	display: block;
+	overflow: hidden;
 	position: absolute;
 	top: 0;
+	right: 0;
+	bottom: 0;
 	left: 0;
-	margin: 0 auto;
-	overflow: hidden;
-	max-width: 100%;
-	max-height: 100%;
 }
 
-.attachment-preview.type-audio .thumbnail,
-.attachment-preview.type-video .thumbnail {
-	z-index: 1;
-	margin: 1%;
-	max-width: 98%;
-	max-height: 98%;
+.attachment .portrait img {
+	max-width: 100%;
 }
 
-.media-frame-content .attachment-preview.type-audio .icon,
-.media-frame-content .attachment-preview.type-video .icon {
-	z-index: 2;
-	background: #f1f1f1;
-	position: relative;
-	padding: 0;
-	top: 15%;
-	left: auto;
-	right: auto;
+.attachment .landscape img {
+	max-height: 100%;
 }
 
-.attachment-preview.type-audio .filename,
-.attachment-preview.type-video .filename {
-	z-index: 3;
-}
-
-.attachment-preview .thumbnail:after {
+.attachment .thumbnail:after {
 	content: '';
 	display: block;
 	position: absolute;
@@ -848,7 +819,6 @@
 	bottom: 0;
 	overflow: hidden;
 	max-height: 100%;
-
 	word-wrap: break-word;
 	text-align: center;
 	font-weight: bold;
@@ -861,11 +831,6 @@
 	padding: 5px 10px;
 }
 
-.attachment-preview .thumbnail {
-	width: 199px;
-	height: 199px;
-}
-
 .attachment .thumbnail img {
 	position: absolute;
 }
@@ -907,8 +872,8 @@
 	width: 24px;
 	position: absolute;
 	z-index: 10;
-	top: -6px;
-	right: -6px;
+	top: 0;
+	right: 0;
 	outline: none;
 	background: #eee;
 	-webkit-box-shadow: 0 0 0 1px #fff, 0 0 0 2px rgba( 0, 0, 0, 0.15 );
@@ -930,12 +895,15 @@
 	display: block;
 }
 
+.selected.attachment:focus,
 .attachment.details,
 .media-frame.mode-grid .selected.attachment {
-	-webkit-box-shadow: 0 0 0 1px #fff,
-				0 0 0 5px #1e8cbe;
-	box-shadow: 0 0 0 1px #fff,
-				0 0 0 5px #1e8cbe;
+	-webkit-box-shadow:
+		inset 0 0 0 3px #fff,
+		inset 0 0 0 7px #1e8cbe;
+	box-shadow:
+		inset 0 0 0 3px #fff,
+		inset 0 0 0 7px #1e8cbe;
 }
 
 .attachment.details .check,
@@ -942,10 +910,12 @@
 .attachment.selected .check:focus,
 .media-frame.mode-grid .attachment.selected .check {
 	background-color: #1e8cbe;
-	-webkit-box-shadow: 0 0 0 1px #fff,
-				0 0 0 2px #1e8cbe;
-	box-shadow: 0 0 0 1px #fff,
-				0 0 0 2px #1e8cbe;
+	-webkit-box-shadow:
+		0 0 0 1px #fff,
+		0 0 0 2px #1e8cbe;
+	box-shadow:
+		0 0 0 1px #fff,
+		0 0 0 2px #1e8cbe;
 }
 
 .media-frame.mode-grid .attachment .check {
@@ -971,7 +941,7 @@
 	position: relative;
 	display: block;
 	width: 100%;
-	margin: -1px 0 0;
+	margin: 0;
 	padding: 8px;
 	font-size: 12px;
 	-webkit-border-radius: 0;
@@ -1381,16 +1351,31 @@
 .media-selection .attachments {
 	display: inline-block;
 	height: 48px;
-	margin-top: 5px;
+	margin: 6px;
+	padding: 0;
 	overflow: hidden;
 	vertical-align: top;
 }
 
+.media-selection .attachment {
+	width: 48px;
+	padding: 0;
+	margin: 0;
+	box-shadow: none; 
+}
+
+.media-selection .attachment .thumbnail {
+	top: 4px;
+	right: 4px;
+	bottom: 4px;
+	left: 4px;
+}
+
 .media-selection .attachment .icon {
 	width: 50%;
 }
-
-.attachment.selection.selected {
+/*
+.attachment.selection.selected .thumbnail {
 	-webkit-box-shadow: none;
 	box-shadow: none;
 }
@@ -1413,8 +1398,8 @@
 		0 0 0 1px #fff,
 		0 0 0 4px #1e8cbe;
 }
-
-.media-selection .attachment.selection.details {
+*/
+.media-selection .attachment.selection.details .thumbnail {
 	-webkit-box-shadow:
 		0 0 0 1px #fff,
 		0 0 0 3px #1e8cbe;
@@ -2914,3 +2899,51 @@
 		max-width: none !important;
 	}
 }
+
+.attachments[data-columns="1"] .attachment {
+	width: 100%;
+}
+
+.attachments[data-columns="2"] .attachment {
+	width: 50%;
+}
+
+.attachments[data-columns="3"] .attachment {
+	width: 33.3%;
+}
+
+.attachments[data-columns="4"] .attachment {
+	width: 25%;
+}
+
+.attachments[data-columns="5"] .attachment {
+	width: 20%;
+}
+
+.attachments[data-columns="6"] .attachment {
+	width: 16.6%;
+}
+
+.attachments[data-columns="7"] .attachment {
+	width: 14.2%;
+}
+
+.attachments[data-columns="8"] .attachment {
+	width: 12.5%;
+}
+
+.attachments[data-columns="9"] .attachment {
+	width: 11.1%;
+}
+
+.attachments[data-columns="10"] .attachment {
+	width: 10%;
+}
+
+.attachments[data-columns="11"] .attachment {
+	width: 9%;
+}
+
+.attachments[data-columns="12"] .attachment {
+	width: 8.3%;
+}
Index: src/wp-includes/js/media-views.js
===================================================================
--- src/wp-includes/js/media-views.js	(revision 29372)
+++ src/wp-includes/js/media-views.js	(working copy)
@@ -630,14 +630,6 @@
 				}) );
 			}
 
-			if ( ! this.get('edge') ) {
-				this.set( 'edge', 150 );
-			}
-
-			if ( ! this.get('gutter') ) {
-				this.set( 'gutter', 8 );
-			}
-
 			this.resetDisplays();
 		},
 
@@ -835,12 +827,12 @@
 			content:         'browse',
 			toolbar:         'gallery-edit',
 
-			describe:        true,
-			displaySettings: true,
-			dragInfo:        true,
-			edge:            199,
-			editing:         false,
-			priority:        60,
+			describe:         true,
+			displaySettings:  true,
+			dragInfo:         true,
+			idealColumnWidth: 170,
+			editing:          false,
+			priority:         60,
 
 			// Don't sync the selection, as the Edit Gallery library
 			// *is* the selection.
@@ -989,12 +981,12 @@
 			// Region mode defaults.
 			content:      'browse',
 
-			describe:     true,
-			dragInfo:     true,
-			edge:         199,
-			editing:      false,
-			priority:     60,
-			SettingsView: false,
+			describe:         true,
+			dragInfo:         true,
+			idealColumnWidth: 170,
+			editing:          false,
+			priority:         60,
+			SettingsView:     false,
 
 			// Don't sync the selection, as the Edit {Collection} library
 			// *is* the selection.
@@ -2178,8 +2170,9 @@
 				display:    state.has('display') ? state.get('display') : state.get('displaySettings'),
 				dragInfo:   state.get('dragInfo'),
 
-				suggestedWidth:  state.get('suggestedWidth'),
-				suggestedHeight: state.get('suggestedHeight'),
+				idealColumnWidth: state.get('idealColumnWidth'),
+				suggestedWidth:   state.get('suggestedWidth'),
+				suggestedHeight:  state.get('suggestedHeight'),
 
 				AttachmentView: state.get('AttachmentView')
 			});
@@ -4805,8 +4798,8 @@
 		arrowEvent: function( event ) {
 			var attachment = $('.attachments-browser .attachment'),
 				attachmentsWidth = $('.attachments-browser .attachments').width(),
-				thumbnailWidth = attachment.first().innerWidth() + 16,
-				thumbnailsPerRow = Math.floor(attachmentsWidth/thumbnailWidth),
+				thumbnailWidth = attachment.first().width(),
+				thumbnailsPerRow = Math.round( attachmentsWidth / thumbnailWidth ),
 				totalThumnails = attachment.length,
 				totalRows = Math.ceil(totalThumnails/thumbnailsPerRow),
 				thisIndex = attachment.filter( ':focus' ).index(),
@@ -5218,8 +5211,6 @@
 			tabIndex: -1
 		},
 
-		cssTemplate: media.template('attachments-css'),
-
 		initialize: function() {
 			this.el.id = _.uniqueId('__attachments-view-');
 
@@ -5228,7 +5219,8 @@
 				refreshThreshold:   3,
 				AttachmentView:     media.view.Attachment,
 				sortable:           false,
-				resize:             true
+				resize:             true,
+				idealColumnWidth:   150
 			});
 
 			this._viewsByCid = {};
@@ -5258,21 +5250,21 @@
 
 			this.initSortable();
 
-			_.bindAll( this, 'css' );
-			this.model.on( 'change:edge change:gutter', this.css, this );
-			this._resizeCss = _.debounce( _.bind( this.css, this ), this.refreshSensitivity );
+			_.bindAll( this, 'setColumns' );
+
 			if ( this.options.resize ) {
-				$(window).on( 'resize.attachments', this._resizeCss );
+				$( window ).on( 'resize.attachments', this.setColumns );
 			}
 
-			// Call this.css() after this view has been rendered in the DOM so
+			// Call this.setColumns() after this view has been rendered in the DOM so
 			// attachments get proper width applied.
-			_.defer( this.css, this );
+			_.defer( this.setColumns, this );
 		},
 
 		dispose: function() {
 			this.collection.props.off( null, null, this );
-			$(window).off( 'resize.attachments', this._resizeCss );
+			$( window ).off( 'resize.attachments', this.setColumns );
+
 			/**
 			 * call 'dispose' directly on the parent class
 			 */
@@ -5279,35 +5271,14 @@
 			media.View.prototype.dispose.apply( this, arguments );
 		},
 
-		css: function() {
-			var $css = $( '#' + this.el.id + '-css' );
+		setColumns: function() {
+			var prev = this.columns;
 
-			if ( $css.length ) {
-				$css.remove();
-			}
+			this.columns = Math.round( this.$el.width() / this.options.idealColumnWidth );
 
-			media.view.Attachments.$head().append( this.cssTemplate({
-				id:     this.el.id,
-				edge:   this.edge(),
-				gutter: this.model.get('gutter')
-			}) );
-		},
-		/**
-		 * @returns {Number}
-		 */
-		edge: function() {
-			var edge = this.model.get('edge'),
-				gutter, width, columns;
-
-			if ( ! this.$el.is(':visible') ) {
-				return edge;
+			if ( prev !== this.columns ) {
+				this.$el.attr( 'data-columns', this.columns );
 			}
-
-			gutter  = this.model.get('gutter') * 2;
-			width   = this.$el.width() - gutter;
-			columns = Math.ceil( width / ( edge + gutter ) );
-			edge = Math.floor( ( width - ( columns * gutter ) ) / columns );
-			return edge;
 		},
 
 		initSortable: function() {
@@ -5453,13 +5424,6 @@
 				});
 			}
 		}
-	}, {
-		$head: (function() {
-			var $head;
-			return function() {
-				return $head = $head || $('head');
-			};
-		}())
 	});
 
 	/**
@@ -5895,6 +5859,7 @@
 				model:                this.model,
 				sortable:             this.options.sortable,
 				scrollElement:        this.options.scrollElement,
+				idealColumnWidth:     this.options.idealColumnWidth,
 
 				// The single `Attachment` view to be used in the `Attachments` view.
 				AttachmentView: this.options.AttachmentView
@@ -6003,10 +5968,7 @@
 				controller: this.controller,
 				collection: this.collection,
 				selection:  this.collection,
-				model:      new Backbone.Model({
-					edge:   40,
-					gutter: 5
-				})
+				model:      new Backbone.Model()
 			});
 
 			this.views.set( '.selection-view', this.attachments );
Index: src/wp-includes/media-template.php
===================================================================
--- src/wp-includes/media-template.php	(revision 29373)
+++ src/wp-includes/media-template.php	(working copy)
@@ -414,24 +414,26 @@
 
 	<script type="text/html" id="tmpl-attachment">
 		<div class="attachment-preview js--select-attachment type-{{ data.type }} subtype-{{ data.subtype }} {{ data.orientation }}">
-			<# if ( data.uploading ) { #>
-				<div class="media-progress-bar"><div></div></div>
-			<# } else if ( 'image' === data.type ) { #>
-				<div class="thumbnail">
+			<div class="thumbnail">
+				<# if ( data.uploading ) { #>
+					<div class="media-progress-bar"><div>
+				<# } else if ( 'image' === data.type ) { #>
 					<div class="centered">
 						<img src="{{ data.size.url }}" draggable="false" alt="" />
 					</div>
-				</div>
-			<# } else {
-				if ( data.thumb && data.thumb.src && data.thumb.src !== data.icon ) {
-				#><img src="{{ data.thumb.src }}" class="thumbnail" draggable="false" /><#
-				} else {
-				#><img src="{{ data.icon }}" class="icon" draggable="false" /><#
-				} #>
-				<div class="filename">
-					<div>{{ data.filename }}</div>
-				</div>
-			<# } #>
+				<# } else { #>
+					<div class="centered">
+						<# if ( data.thumb && data.thumb.src && data.thumb.src !== data.icon ) { #>
+							<img src="{{ data.thumb.src }}" class="thumbnail" draggable="false" />
+						<# } else { #>
+							<img src="{{ data.icon }}" class="icon" draggable="false" />
+						<# } #>
+					</div>
+					<div class="filename">
+						<div>{{ data.filename }}</div>
+					</div>
+				<# } #>
+			</div>
 			<# if ( data.buttons.close ) { #>
 				<a class="close media-modal-icon" href="#" title="<?php esc_attr_e('Remove'); ?>"></a>
 			<# } #>
@@ -822,35 +824,6 @@
 		</div>
 	</script>
 
-	<script type="text/html" id="tmpl-attachments-css">
-		<style type="text/css" id="{{ data.id }}-css">
-			#{{ data.id }} {
-				padding: 0 {{ data.gutter }}px;
-			}
-
-			#{{ data.id }} .attachment {
-				margin: {{ data.gutter }}px;
-				width: {{ data.edge }}px;
-			}
-
-			#{{ data.id }} .attachment-preview,
-			#{{ data.id }} .attachment-preview .thumbnail {
-				width: {{ data.edge }}px;
-				height: {{ data.edge }}px;
-			}
-
-			#{{ data.id }} .portrait .thumbnail img {
-				max-width: {{ data.edge }}px;
-				height: auto;
-			}
-
-			#{{ data.id }} .landscape .thumbnail img {
-				width: auto;
-				max-height: {{ data.edge }}px;
-			}
-		</style>
-	</script>
-
 	<script type="text/html" id="tmpl-image-details">
 		<div class="media-embed">
 			<div class="embed-media-settings">
