Index: src/wp-includes/media.php
===================================================================
--- src/wp-includes/media.php	(revision 30698)
+++ src/wp-includes/media.php	(working copy)
@@ -59,10 +59,12 @@
 		// if no width is set, default to the theme content width if available
 	}
 	elseif ( $size == 'large' ) {
-		// We're inserting a large size image into the editor. If it's a really
-		// big image we'll scale it down to fit reasonably within the editor
-		// itself, and within the theme's content width if it's known. The user
-		// can resize it in the editor if they wish.
+		/*
+		 * We're inserting a large size image into the editor. If it's a really
+		 * big image we'll scale it down to fit reasonably within the editor
+		 * itself, and within the theme's content width if it's known. The user
+		 * can resize it in the editor if they wish.
+		 */
 		$max_width = intval(get_option('large_size_w'));
 		$max_height = intval(get_option('large_size_h'));
 		if ( intval($content_width) > 0 )
@@ -109,7 +111,7 @@
  *
  * @since 2.5.0
  *
- * @param int|string $width Optional. Width attribute value.
+ * @param int|string $width  Optional. Width attribute value.
  * @param int|string $height Optional. Height attribute value.
  * @return string HTML attributes for width and, or height.
  */
@@ -140,7 +142,7 @@
  *
  * @since 2.5.0
  *
- * @param int $id Attachment ID for image.
+ * @param int          $id   Attachment ID for image.
  * @param array|string $size Optional, default is 'medium'. Size of image, either array or string.
  * @return bool|array False on failure, array on success.
  */
@@ -297,11 +299,11 @@
  *
  * @since 2.5.0
  *
- * @param int $id Attachment ID.
- * @param string $alt Image Description for the alt attribute.
+ * @param int    $id    Attachment ID.
+ * @param string $alt   Image Description for the alt attribute.
  * @param string $title Image Description for the title attribute.
  * @param string $align Part of the class name for aligning the image.
- * @param string $size Optional. Default is 'medium'.
+ * @param string $size  Optional. The registered image size. Default is 'medium'.
  * @return string HTML IMG element for given image attachment
  */
 function get_image_tag($id, $alt, $title, $align, $size='medium') {
@@ -352,10 +354,10 @@
  *
  * @since 2.5.0
  *
- * @param int $current_width Current width of the image.
+ * @param int $current_width  Current width of the image.
  * @param int $current_height Current height of the image.
- * @param int $max_width Optional. Maximum wanted width.
- * @param int $max_height Optional. Maximum wanted height.
+ * @param int $max_width      Optional. Maximum wanted width.
+ * @param int $max_height     Optional. Maximum wanted height.
  * @return array First item is the width, the second item is the height.
  */
 function wp_constrain_dimensions( $current_width, $current_height, $max_width=0, $max_height=0 ) {
@@ -405,6 +407,17 @@
 		$h = $max_height; // Round it up
 	}
 
+	/**
+	 * Constrain image dimensions.
+	 *
+	 * @since 4.1
+	 *
+	 * @param array $dimensions     The image width and height
+	 * @param int 	$current_width  The current width of the image.
+	 * @param int 	$current_height The current height of the image.
+	 * @param int 	$max_width      The maximum width permitted.
+	 * @param int 	$max_height     The maximum height permitted.
+	 */
 	return apply_filters( 'wp_constrain_dimensions', array( $w, $h ), $current_width, $current_height, $max_width, $max_height );
 }
 
@@ -531,10 +544,11 @@
  *
  * @since 2.5.0
  *
- * @param string $file File path.
- * @param int $width Image width.
- * @param int $height Image height.
- * @param bool $crop Optional, default is false. Whether to crop image to specified height and width or resize.
+ * @param string $file   File path.
+ * @param int    $width  Image width.
+ * @param int    $height Image height.
+ * @param bool   $crop   Optional, default is false. Whether to crop image to
+ *                       specified height and width or resize.
  * @return bool|array False, if no image was created. Metadata array on success.
  */
 function image_make_intermediate_size( $file, $width, $height, $crop = false ) {
@@ -576,8 +590,9 @@
  * @since 2.5.0
  * @see add_image_size()
  *
- * @param int $post_id Attachment ID for image.
- * @param array|string $size Optional, default is 'thumbnail'. Size of image, either array or string.
+ * @param int          $post_id Attachment ID for image.
+ * @param array|string $size    Optional, default is 'thumbnail'. Size of image,
+ *                              either array or string.
  * @return bool|array False on failure or array of file path, width, and height on success.
  */
 function image_get_intermediate_size($post_id, $size='thumbnail') {
@@ -631,9 +646,12 @@
 }
 
 /**
- * Get the available image sizes
+ * Get the available image sizes.
+ *
  * @since 3.0.0
- * @return array Returns a filtered array of image size strings
+ *
+ * @global $_wp_additional_image_sizes
+ * @return array Returns a filtered array of image size strings.
  */
 function get_intermediate_image_sizes() {
 	global $_wp_additional_image_sizes;
@@ -659,9 +677,9 @@
  *
  * @since 2.5.0
  *
- * @param int $attachment_id Image attachment ID.
- * @param string $size Optional, default is 'thumbnail'.
- * @param bool $icon Optional, default is false. Whether it is an icon.
+ * @param int    $attachment_id Image attachment ID.
+ * @param string $size          Optional, default is 'thumbnail'.
+ * @param bool   $icon          Optional, default is false. Whether it is an icon.
  * @return bool|array Returns an array (url, width, height), or false, if no image is available.
  */
 function wp_get_attachment_image_src($attachment_id, $size='thumbnail', $icon = false) {
@@ -752,6 +770,7 @@
  * dynamically add/remove itself so as to only filter post thumbnails
  *
  * @since 2.9.0
+ *
  * @param array $attr Attributes including src, class, alt, title
  * @return array
  */
@@ -793,7 +812,7 @@
  *
  * @since 2.6.0
  *
- * @param array $attr {
+ * @param array  $attr {
  *     Attributes of the caption shortcode.
  *
  *     @type string $id      ID of the div element for the caption.
@@ -1401,12 +1420,12 @@
 add_shortcode( 'playlist', 'wp_playlist_shortcode' );
 
 /**
- * Provide a No-JS Flash fallback as a last resort for audio / video
+ * Provide a No-JS Flash fallback as a last resort for audio / video.
  *
  * @since 3.6.0
  *
- * @param string $url
- * @return string Fallback HTML
+ * @param string $url The media element URL.
+ * @return string Fallback HTML.
  */
 function wp_mediaelement_fallback( $url ) {
 	/**
@@ -1424,7 +1443,8 @@
  * Return a filtered list of WP-supported audio formats.
  *
  * @since 3.6.0
- * @return array
+ *
+ * @return array Supported audio formats.
  */
 function wp_get_audio_extensions() {
 	/**
@@ -1444,7 +1464,7 @@
  * @since 3.9.0
  *
  * @param WP_Post $attachment The current attachment, provided for context.
- * @param string  $context    The context. Accepts 'edit', 'display'. Default 'display'.
+ * @param string  $context    Optional. The context. Accepts 'edit', 'display'. Default 'display'.
  * @return array Key/value pairs of field keys to labels.
  */
 function wp_get_attachment_id3_keys( $attachment, $context = 'display' ) {
@@ -1481,7 +1501,7 @@
  *
  * @since 3.6.0
  *
- * @param array $attr {
+ * @param array  $attr {
  *     Attributes of the audio shortcode.
  *
  *     @type string $src      URL to the source of the audio file. Default empty.
@@ -1648,10 +1668,11 @@
 add_shortcode( 'audio', 'wp_audio_shortcode' );
 
 /**
- * Return a filtered list of WP-supported video formats
+ * Return a filtered list of WP-supported video formats.
  *
  * @since 3.6.0
- * @return array
+ *
+ * @return array Supported video formats.
  */
 function wp_get_video_extensions() {
 	/**
@@ -1673,7 +1694,7 @@
  *
  * @since 3.6.0
  *
- * @param array $attr {
+ * @param array  $attr {
  *     Attributes of the shortcode.
  *
  *     @type string $src      URL to the source of the video file. Default empty.
@@ -1893,6 +1914,8 @@
  * Display previous image link that has the same post parent.
  *
  * @since 2.5.0
+ * @see adjacent_image_link()
+ *
  * @param string $size Optional, default is 'thumbnail'. Size of image, either array or string. 0 or 'none' will default to post_title or $text;
  * @param string $text Optional, default is false. If included, link will reflect $text variable.
  * @return string HTML content.
@@ -1905,6 +1928,8 @@
  * Display next image link that has the same post parent.
  *
  * @since 2.5.0
+ * @see adjacent_image_link()
+ *
  * @param string $size Optional, default is 'thumbnail'. Size of image, either array or string. 0 or 'none' will default to post_title or $text;
  * @param string $text Optional, default is false. If included, link will reflect $text variable.
  * @return string HTML content.
@@ -1921,6 +1946,9 @@
  * @since 2.5.0
  *
  * @param bool $prev Optional. Default is true to display previous link, false for next.
+ * @param str  $size Optional. The image size. Default is 'thumbnail'.
+ * @param bool $text Optional. If string, then will be link text. Default is false.
+ * @return string The adjacent image link.
  */
 function adjacent_image_link($prev = true, $size = 'thumbnail', $text = false) {
 	$post = get_post();
@@ -2009,7 +2037,8 @@
  * @since 3.5.0
  * @see get_attachment_taxonomies()
  *
- * @param string $output The type of output to return, either taxonomy 'names' or 'objects'. 'names' is the default.
+ * @param string $output The type of output to return, either taxonomy 'names' or 'objects'.
+ *                       'names' is the default.
  * @return array The names of all taxonomy of $object_type.
  */
 function get_taxonomies_for_attachments( $output = 'names' ) {
@@ -2031,13 +2060,14 @@
 
 /**
  * Create new GD image resource with transparency support
- * @TODO: Deprecate if possible.
  *
+ * @todo: Deprecate if possible.
+ *
  * @since 2.9.0
  *
- * @param int $width Image width
- * @param int $height Image height
- * @return resource resource
+ * @param int $width  Image width.
+ * @param int $height Image height.
+ * @return resource The GD image resource.
  */
 function wp_imagecreatetruecolor($width, $height) {
 	$img = imagecreatetruecolor($width, $height);
@@ -2055,10 +2085,11 @@
  * @see WP_Embed::register_handler()
  *
  * @global WP_Embed $wp_embed
- * @param string   $id
- * @param string   $regex
- * @param callable $callback
- * @param int      $priority
+ * @param string   $id       An internal ID/name for the handler. Needs to be unique.
+ * @param string   $regex    The regex that will be used to see if this handler should be used for a URL.
+ * @param callback $callback The callback function that will be called if the regex is matched.
+ * @param int      $priority Optional. Used to specify the order in which the registered handlers will
+ *                           be tested (default: 10).
  */
 function wp_embed_register_handler( $id, $regex, $callback, $priority = 10 ) {
 	global $wp_embed;
@@ -2072,8 +2103,8 @@
  * @see WP_Embed::unregister_handler()
  *
  * @global WP_Embed $wp_embed
- * @param string $id
- * @param int    $priority
+ * @param string $id       The handler ID that should be removed.
+ * @param int    $priority Optional. The priority of the handler to be removed (default: 10).
  */
 function wp_embed_unregister_handler( $id, $priority = 10 ) {
 	global $wp_embed;
@@ -2121,11 +2152,12 @@
  * Based on a supplied width/height example, return the biggest possible dimensions based on the max width/height.
  *
  * @since 2.9.0
+ * @see wp_constrain_dimensions()
  *
- * @param int $example_width The width of an example embed.
+ * @param int $example_width  The width of an example embed.
  * @param int $example_height The height of an example embed.
- * @param int $max_width The maximum allowed width.
- * @param int $max_height The maximum allowed height.
+ * @param int $max_width      The maximum allowed width.
+ * @param int $max_height     The maximum allowed height.
  * @return array The maximum possible width and height based on the example ratio.
  */
 function wp_expand_dimensions( $example_width, $example_height, $max_width, $max_height ) {
@@ -2143,8 +2175,8 @@
  * @since 2.9.0
  * @see WP_oEmbed
  *
- * @param string $url The URL that should be embedded.
- * @param array $args Additional arguments and parameters.
+ * @param string $url  The URL that should be embedded.
+ * @param array  $args Additional arguments and parameters.
  * @return false|string False on failure or the embed HTML on success.
  */
 function wp_oembed_get( $url, $args = '' ) {
@@ -2159,9 +2191,9 @@
  * @since 2.9.0
  * @see WP_oEmbed
  *
- * @param string $format The format of URL that this provider can handle. You can use asterisks as wildcards.
- * @param string $provider The URL to the oEmbed provider.
- * @param boolean $regex Whether the $format parameter is in a regex format.
+ * @param string  $format   The format of URL that this provider can handle. You can use asterisks as wildcards.
+ * @param string  $provider The URL to the oEmbed provider.
+ * @param boolean $regex    Whether the $format parameter is in a regex format.
  */
 function wp_oembed_add_provider( $format, $provider, $regex = false ) {
 	require_once( ABSPATH . WPINC . '/class-oembed.php' );
@@ -2181,6 +2213,7 @@
  * @see WP_oEmbed
  *
  * @param string $format The URL format for the oEmbed provider to remove.
+ * @return bool Was the provider removed successfully?
  */
 function wp_oembed_remove_provider( $format ) {
 	require_once( ABSPATH . WPINC . '/class-oembed.php' );
@@ -2206,6 +2239,7 @@
  * it hasn't, then it will load the embeds library.
  *
  * @since 2.9.0
+ * @see wp_embed_register_handler()
  */
 function wp_maybe_load_embeds() {
 	/**
@@ -2250,10 +2284,10 @@
  * @see WP_Embed::register_handler()
  * @see WP_Embed::shortcode()
  *
- * @param array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}.
- * @param array $attr Embed attributes.
- * @param string $url The original URL that was matched by the regex.
- * @param array $rawattr The original unmodified attributes.
+ * @param array  $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}.
+ * @param array  $attr    Embed attributes.
+ * @param string $url     The original URL that was matched by the regex.
+ * @param array  $rawattr The original unmodified attributes.
  * @return string The embed HTML.
  */
 function wp_embed_handler_googlevideo( $matches, $attr, $url, $rawattr ) {
@@ -2296,6 +2330,7 @@
 function wp_embed_handler_youtube( $matches, $attr, $url, $rawattr ) {
 	global $wp_embed;
 	$embed = $wp_embed->autoembed( "https://youtube.com/watch?v={$matches[2]}" );
+
 	/**
 	 * Filter the YoutTube embed output.
 	 *
@@ -2343,10 +2378,10 @@
  *
  * @since 3.6.0
  *
- * @param array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}.
- * @param array $attr Embed attributes.
- * @param string $url The original URL that was matched by the regex.
- * @param array $rawattr The original unmodified attributes.
+ * @param array  $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}.
+ * @param array  $attr    Embed attributes.
+ * @param string $url     The original URL that was matched by the regex.
+ * @param array  $rawattr The original unmodified attributes.
  * @return string The embed HTML.
  */
 function wp_embed_handler_video( $matches, $attr, $url, $rawattr ) {
@@ -2417,11 +2452,11 @@
  * Returns a WP_Image_Editor instance and loads file into it.
  *
  * @since 3.5.0
- * @access public
+ * @see _wp_image_editor_choose()
  *
- * @param string $path Path to file to load
- * @param array $args Additional data. Accepts { 'mime_type'=>string, 'methods'=>{string, string, ...} }
- * @return WP_Image_Editor|WP_Error
+ * @param string $path Path to the file to load.
+ * @param array  $args Additional data. Accepts { 'mime_type'=>string, 'methods'=>{string, string, ...} }.
+ * @return WP_Image_Editor|WP_Error The WP_Image_Editor object if successful, an WP_Error object otherwise.
  */
 function wp_get_image_editor( $path, $args = array() ) {
 	$args['path'] = $path;
@@ -2454,10 +2489,10 @@
  * Tests whether there is an editor that supports a given mime type or methods.
  *
  * @since 3.5.0
- * @access public
+ * @see _wp_image_editor_choose()
  *
  * @param string|array $args Array of requirements. Accepts { 'mime_type'=>string, 'methods'=>{string, string, ...} }
- * @return boolean true if an eligible editor is found; false otherwise
+ * @return boolean true if an eligible editor is found; false otherwise.
  */
 function wp_image_editor_supports( $args = array() ) {
 	return (bool) _wp_image_editor_choose( $args );
@@ -2513,6 +2548,8 @@
  * Prints default plupload arguments.
  *
  * @since 3.4.0
+ *
+ * @global $wp_scripts
  */
 function wp_plupload_default_settings() {
 	global $wp_scripts;
@@ -2783,6 +2820,14 @@
  * all media JS APIs.
  *
  * @since 3.5.0
+ *
+ * @global $content_width
+ * @global $wpdb
+ * @global $wp_locale
+ * @param array $args {
+ *		@type int|WP_Post A post object or ID.
+ * }
+ * @return array List of media view settings.
  */
 function wp_enqueue_media( $args = array() ) {
 
@@ -3126,8 +3171,9 @@
  * @since 3.6.0
  *
  * @param string $content A string which might contain media data.
- * @param array $types array of media types: 'audio', 'video', 'object', 'embed', or 'iframe'
- * @return array A list of found HTML media embeds
+ * @param array  $types   Optional. An array of media types: 'audio', 'video', 'object', 'embed',
+ *                        or 'iframe'. Defaults to null.
+ * @return array A list of found HTML media embeds.
  */
 function get_media_embedded_in_content( $content, $types = null ) {
 	$html = array();
@@ -3155,7 +3201,7 @@
  * @param int|WP_Post $post Optional. Post ID or object.
  * @param bool        $html Whether to return HTML or data in the array.
  * @return array A list of arrays, each containing gallery data and srcs parsed
- *		         from the expanded shortcode.
+ *               from the expanded shortcode.
  */
 function get_post_galleries( $post, $html = true ) {
 	if ( ! $post = get_post( $post ) )
@@ -3205,7 +3251,7 @@
  * @since 3.6.0
  *
  * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
- * @param bool        $html Whether to return HTML or data.
+ * @param bool        $html Optional. Whether to return HTML or data. Default is true.
  * @return string|array Gallery data and srcs parsed from the expanded shortcode.
  */
 function get_post_gallery( $post = 0, $html = true ) {
@@ -3231,7 +3277,7 @@
  *
  * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
  * @return array A list of lists, each containing image srcs parsed.
- *		from an expanded shortcode
+ *               from an expanded shortcode
  */
 function get_post_galleries_images( $post = 0 ) {
 	$galleries = get_post_galleries( $post, false );
@@ -3282,7 +3328,6 @@
  * @since 4.0.0
  *
  * @global wpdb $wpdb WordPress database abstraction object.
- *
  * @param string $url The URL to resolve.
  * @return int The found post ID.
  */
@@ -3312,7 +3357,6 @@
  * @since 4.0.0
  *
  * @global $wp_version
- *
  * @return array The relevant CSS file URLs.
  */
 function wpview_media_sandbox_styles() {
