Index: src/wp-includes/media.php
===================================================================
--- src/wp-includes/media.php	(revision 35558)
+++ src/wp-includes/media.php	(working copy)
@@ -983,23 +983,24 @@
 		return false;
 	}
 
-	// Don't add srcset attributes to (animated) gifs that are inserted at full size.
-	if ( isset( $image_sizes['thumbnail']['mime-type'] ) && 'image/gif' === $image_sizes['thumbnail']['mime-type'] &&
-		false !== strpos( $image_src, $image_meta['file'] ) ) {
+	$image_basename = wp_basename( $image_meta['file'] );
+	$image_baseurl = _wp_upload_dir_baseurl();
 
+	/*
+	 * WordPress flattens animated GIFs into one frame when generating intermediate sizes.
+	 * To avoid hiding animation in user content, if src is a full size GIF, a srcset attribute is not generated.
+	 * If src is an intermediate size GIF, the full size is excluded from srcset to keep a flattened GIF from becoming animated.
+	 */
+	if ( ! isset( $image_sizes['thumbnail']['mime-type'] ) || 'image/gif' !== $image_sizes['thumbnail']['mime-type'] ) {
+		$image_sizes['full'] = array(
+			'width'  => $image_meta['width'],
+			'height' => $image_meta['height'],
+			'file'   => $image_basename,
+		);
+	} elseif ( strpos( $image_src, $image_meta['file'] ) ) {
 		return false;
 	}
 
-	$image_basename = wp_basename( $image_meta['file'] );
-	$image_baseurl = _wp_upload_dir_baseurl();
-
-	// Add full size to the '$image_sizes' array.
-	$image_sizes['full'] = array(
-		'width'  => $image_meta['width'],
-		'height' => $image_meta['height'],
-		'file'   => $image_basename,
-	);
-
 	// Uploads are (or have been) in year/month sub-directories.
 	if ( $image_basename !== $image_meta['file'] ) {
 		$dirname = dirname( $image_meta['file'] );
Index: tests/phpunit/tests/media.php
===================================================================
--- tests/phpunit/tests/media.php	(revision 35558)
+++ tests/phpunit/tests/media.php	(working copy)
@@ -996,10 +996,15 @@
 			)
 		);
 
-		$image_src = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image_meta['file'];
+		$full_src  = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image_meta['file'];
+		$large_src = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image_meta['sizes']['large']['file'];
+
 		// Test with soft resized size array.
 		$size_array = array(900, 450);
 
-		$this->assertFalse( wp_calculate_image_srcset( $image_src, $size_array, $image_meta ) );
+		// Full size GIFs should not return a srcset.
+		$this->assertFalse( wp_calculate_image_srcset( $full_src, $size_array, $image_meta ) );
+		// Intermediate sized GIFs should not include the full size in the srcset.
+		$this->assertFalse( strpos( wp_calculate_image_srcset( $large_src, $size_array, $image_meta ), $full_src ) );
 	}
 }
