Index: admin/media.php
===================================================================
--- admin/media.php	(revision 3152)
+++ admin/media.php	(revision 3153)
@@ -56,5 +56,5 @@
 }
 
-# Get query in any
+# Get query if any
 $q = isset($_REQUEST['q']) ? $_REQUEST['q'] : null;
 
@@ -83,6 +83,7 @@
 
 $popup = (integer) !empty($_REQUEST['popup']);
-
-$page_url_params = new ArrayObject(array('popup' => $popup,'post_id' => $post_id));
+$select = !empty($_REQUEST['select']) ? (integer)$_REQUEST['select'] : 0;	// 0 : none, 1 : single media, >1 : multiple medias
+
+$page_url_params = new ArrayObject(array('popup' => $popup,'select' => $select,'post_id' => $post_id));
 if ($d) {
 	$page_url_params['d'] = $d;
@@ -474,20 +475,34 @@
 }
 
-if ($post_id) {
-	echo '<div class="form-note info"><p>'.sprintf(__('Choose a file to attach to entry %s by clicking on %s'),
-		'<a href="'.$core->getPostAdminURL($post_type,$post_id).'">'.html::escapeHTML($post_title).'</a>',
-		'<img src="images/plus.png" alt="'.__('Attach this file to entry').'" />');
+if ($select) {
+	// Select mode (popup or not)
+	echo '<div class="'.($popup ? 'form-note ' : '').'info"><p>';
+	if ($select == 1) {
+		echo sprintf(__('Select a file by clicking on %s'),'<img src="images/plus.png" alt="'.__('Select this file').'" />');
+	} else {
+		echo sprintf(__('Select files and click on <strong>%s</strong> button'),__('Choose selected medias'));
+	}
 	if ($core_media_writable) {
 		echo ' '.__('or').' '.sprintf('<a href="#fileupload">%s</a>',__('upload a new file'));
 	}
 	echo '</p></div>';
-}
-if ($popup) {
-	echo '<div class="info"><p>'.sprintf(__('Choose a file to insert into entry by clicking on %s'),
-		'<img src="images/plus.png" alt="'.__('Attach this file to entry').'" />');
-	if ($core_media_writable) {
-		echo ' '.__('or').' '.sprintf('<a href="#fileupload">%s</a>',__('upload a new file'));
-	}
-	echo '</p></div>';
+} else {
+	if ($post_id) {
+		echo '<div class="form-note info"><p>'.sprintf(__('Choose a file to attach to entry %s by clicking on %s'),
+			'<a href="'.$core->getPostAdminURL($post_type,$post_id).'">'.html::escapeHTML($post_title).'</a>',
+			'<img src="images/plus.png" alt="'.__('Attach this file to entry').'" />');
+		if ($core_media_writable) {
+			echo ' '.__('or').' '.sprintf('<a href="#fileupload">%s</a>',__('upload a new file'));
+		}
+		echo '</p></div>';
+	}
+	if ($popup) {
+		echo '<div class="info"><p>'.sprintf(__('Choose a file to insert into entry by clicking on %s'),
+			'<img src="images/plus.png" alt="'.__('Attach this file to entry').'" />');
+		if ($core_media_writable) {
+			echo ' '.__('or').' '.sprintf('<a href="#fileupload">%s</a>',__('upload a new file'));
+		}
+		echo '</p></div>';
+	}
 }
 
@@ -512,9 +527,20 @@
 	'</p>';
 
-if (!$popup) {
+if (!$popup || $select > 1) {
+	// Checkboxes and action
 	$fmt_form_media .=
-	'<div class="medias-delete%s">'.
+	'<div class="'.(!$popup ? 'medias-delete' : '').' '.($select > 1 ? 'medias-select' : '').'">'.
 	'<p class="checkboxes-helpers"></p>'.
-	'<p><input type="submit" class="delete" name="delete_medias" value="'.__('Remove selected medias').'"/></p>'.
+	'<p>';
+	if ($select > 1) {
+		$fmt_form_media .=
+		'<input type="submit" class="select" id="select_medias" name="select_medias" value="'.__('Choose selected medias').'"/> ';
+	}
+	if (!$popup) {
+		$fmt_form_media .=
+		'<input type="submit" class="delete" id="delete_medias" name="delete_medias" value="'.__('Remove selected medias').'"/>';
+	}
+	$fmt_form_media .=
+	'</p>'.
 	'</div>';
 }
@@ -531,4 +557,5 @@
 	'<span class="form-note">'.__('Will search into media filename (including path), title and description').'</span>'.
 	form::hidden(array('popup'),$popup).
+	form::hidden(array('select'),$select).
 	form::hidden(array('plugin_id'),$plugin_id).
 	form::hidden(array('post_id'),$post_id).
@@ -562,4 +589,5 @@
 	'<input type="submit" value="'.__('OK').'" />'.
 	form::hidden(array('popup'),$popup).
+	form::hidden(array('select'),$select).
 	form::hidden(array('plugin_id'),$plugin_id).
 	form::hidden(array('post_id'),$post_id).
@@ -746,5 +774,5 @@
 function mediaItemLine($f,$i,$query,$table=false)
 {
-	global $core, $page_url, $popup, $post_id, $plugin_id,$page_url_params;
+	global $core, $page_url, $popup, $select, $post_id, $plugin_id, $page_url_params;
 
 	$fname = $f->basename;
@@ -754,5 +782,5 @@
 
 	if ($f->d) {
-
+		// Folder
 		$link = $core->adminurl->get('admin.media',array_merge($page_url_params,array('d' => html::sanitizeURL($f->relname) )));
 		if ($f->parent) {
@@ -763,4 +791,5 @@
 		}
 	} else {
+		// Item
 		$params = new ArrayObject(
 			array(
@@ -768,4 +797,5 @@
 				'plugin_id' => $plugin_id,
 				'popup' => $popup,
+				'select' => $select,
 				'post_id' => $post_id
 			)
@@ -784,22 +814,39 @@
 
 	$act = '';
-	if ($post_id && !$f->d) {
-		// Media attachment button
-		$act .=
-		'<a class="attach-media" title="'.__('Attach this file to entry').'" href="'.
-		$core->adminurl->get("admin.post.media", array('media_id' => $f->media_id, 'post_id' => $post_id,'attach' => 1)).
-		'">'.
-		'<img src="images/plus.png" alt="'.__('Attach this file to entry').'"/>'.
-		'</a>';
-	}
-	if ($popup && !$f->d) {
-		// Media insertion button
-		$act .= '<a href="'.$link.'"><img src="images/plus.png" alt="'.__('Insert this file into entry').'" '.
-		'title="'.__('Insert this file into entry').'" /></a> ';
+	if (!$f->d) {
+		if ($select > 0) {
+			if ($select == 1) {
+				// Single media selection button
+				$act .= '<a href="'.$link.'"><img src="images/plus.png" alt="'.__('Select this file').'" '.
+				'title="'.__('Select this file').'" /></a> ';
+			} else {
+				// Multiple media selection checkbox
+				$act .= form::checkbox(array('medias[]', 'media_'.rawurlencode($file)),$file);
+			}
+		} else {
+			// Item
+			if ($post_id) {
+				// Media attachment button
+				$act .=
+				'<a class="attach-media" title="'.__('Attach this file to entry').'" href="'.
+				$core->adminurl->get("admin.post.media", array('media_id' => $f->media_id, 'post_id' => $post_id,'attach' => 1)).
+				'">'.
+				'<img src="images/plus.png" alt="'.__('Attach this file to entry').'"/>'.
+				'</a>';
+			}
+			if ($popup) {
+				// Media insertion button
+				$act .= '<a href="'.$link.'"><img src="images/plus.png" alt="'.__('Insert this file into entry').'" '.
+				'title="'.__('Insert this file into entry').'" /></a> ';
+			}
+		}
 	}
 	if ($f->del) {
 		// Deletion button or checkbox
 		if (!$popup && !$f->d) {
-			$act .= form::checkbox(array('medias[]', 'media_'.rawurlencode($file)),$file);
+			if ($select < 2) {
+				// Already set for multiple media selection
+				$act .= form::checkbox(array('medias[]', 'media_'.rawurlencode($file)),$file);
+			}
 		} else {
 			$act .= '<a class="media-remove" '.
@@ -813,4 +860,5 @@
 	}
 
+	// Render markup
 	if (!$table) {
 		$res =
