Index: wp-includes/media.php
===================================================================
--- wp-includes/media.php	(revision 15344)
+++ wp-includes/media.php	(working copy)
@@ -806,6 +806,11 @@
 	if ( empty($attachments) )
 		return '';
 
+	// Another chance for plugins/themes to override the default gallery template.
+	$output = apply_filters('post_gallery_output', '', $attr, $attachments);
+	if ( $output != '' )
+		return $output;
+
 	if ( is_feed() ) {
 		$output = "\n";
 		foreach ( $attachments as $att_id => $attachment )
