Index: wp-content/themes/twentyten/loop.php
===================================================================
--- wp-content/themes/twentyten/loop.php	(revision 23793)
+++ wp-content/themes/twentyten/loop.php	(working copy)
@@ -70,11 +70,32 @@
 				<?php the_content(); ?>
 <?php else : ?>
 				<?php
-					$images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) );
+					if ( function_exists( 'get_post_gallery_images' ) ) :
+						$galleries = get_post_galleries();
+						$images = isset( $galleries[0]['ids'] ) ? explode( ',', $galleries[0]['ids'] ) : false;
+					else :
+						$pattern = get_shortcode_regex();
+						preg_match( "/$pattern/s", get_the_content(), $match );
+						$atts = shortcode_parse_atts( $match[3] );
+						$images = isset( $atts['ids'] ) ? explode( ',', $atts['ids'] ) : false;
+
+						if ( ! $images ) :
+							$images = get_posts( array(
+								'fields'         => 'ids',
+								'numberposts'    => 999,
+								'order'          => 'ASC',
+								'orderby'        => 'menu_order',
+								'post_mime_type' => 'image',
+								'post_parent'    => $post->ID,
+								'post_type'      => 'attachment',
+							) );
+						endif;
+					endif;
+
 					if ( $images ) :
 						$total_images = count( $images );
 						$image = array_shift( $images );
-						$image_img_tag = wp_get_attachment_image( $image->ID, 'thumbnail' );
+						$image_img_tag = wp_get_attachment_image( $image, 'thumbnail' );
 				?>
 						<div class="gallery-thumb">
 							<a class="size-thumbnail" href="<?php the_permalink(); ?>"><?php echo $image_img_tag; ?></a>
