wp/wp-admin/includes/media.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
child 22 8c2e4d02f4ef
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
   143 	} else {
   143 	} else {
   144 		$rel = '';
   144 		$rel = '';
   145 	}
   145 	}
   146 
   146 
   147 	if ( $url ) {
   147 	if ( $url ) {
   148 		$html = '<a href="' . esc_attr( $url ) . '"' . $rel . '>' . $html . '</a>';
   148 		$html = '<a href="' . esc_url( $url ) . '"' . $rel . '>' . $html . '</a>';
   149 	}
   149 	}
   150 
   150 
   151 	/**
   151 	/**
   152 	 * Filters the image HTML markup to send to the editor when inserting an image.
   152 	 * Filters the image HTML markup to send to the editor when inserting an image.
   153 	 *
   153 	 *
   252 /**
   252 /**
   253  * Private preg_replace callback used in image_add_caption().
   253  * Private preg_replace callback used in image_add_caption().
   254  *
   254  *
   255  * @access private
   255  * @access private
   256  * @since 3.4.0
   256  * @since 3.4.0
       
   257  *
       
   258  * @param array $matches Single regex match.
       
   259  * @return string Cleaned up HTML for caption.
   257  */
   260  */
   258 function _cleanup_image_add_caption( $matches ) {
   261 function _cleanup_image_add_caption( $matches ) {
   259 	// Remove any line breaks from inside the tags.
   262 	// Remove any line breaks from inside the tags.
   260 	return preg_replace( '/[\r\n\t]+/', ' ', $matches[0] );
   263 	return preg_replace( '/[\r\n\t]+/', ' ', $matches[0] );
   261 }
   264 }
   383 			/* translators: Audio file genre information. %s: Audio genre name. */
   386 			/* translators: Audio file genre information. %s: Audio genre name. */
   384 			$content .= ' ' . sprintf( __( 'Genre: %s.' ), $meta['genre'] );
   387 			$content .= ' ' . sprintf( __( 'Genre: %s.' ), $meta['genre'] );
   385 		}
   388 		}
   386 
   389 
   387 		// Use image exif/iptc data for title and caption defaults if possible.
   390 		// Use image exif/iptc data for title and caption defaults if possible.
   388 	} elseif ( 0 === strpos( $type, 'image/' ) ) {
   391 	} elseif ( str_starts_with( $type, 'image/' ) ) {
   389 		$image_meta = wp_read_image_metadata( $file );
   392 		$image_meta = wp_read_image_metadata( $file );
   390 
   393 
   391 		if ( $image_meta ) {
   394 		if ( $image_meta ) {
   392 			if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) {
   395 			if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) {
   393 				$title = $image_meta['title'];
   396 				$title = $image_meta['title'];
   417 
   420 
   418 	// Save the data.
   421 	// Save the data.
   419 	$attachment_id = wp_insert_attachment( $attachment, $file, $post_id, true );
   422 	$attachment_id = wp_insert_attachment( $attachment, $file, $post_id, true );
   420 
   423 
   421 	if ( ! is_wp_error( $attachment_id ) ) {
   424 	if ( ! is_wp_error( $attachment_id ) ) {
   422 		// Set a custom header with the attachment_id.
   425 		/*
   423 		// Used by the browser/client to resume creating image sub-sizes after a PHP fatal error.
   426 		 * Set a custom header with the attachment_id.
       
   427 		 * Used by the browser/client to resume creating image sub-sizes after a PHP fatal error.
       
   428 		 */
   424 		if ( ! headers_sent() ) {
   429 		if ( ! headers_sent() ) {
   425 			header( 'X-WP-Upload-Attachment-ID: ' . $attachment_id );
   430 			header( 'X-WP-Upload-Attachment-ID: ' . $attachment_id );
   426 		}
   431 		}
   427 
   432 
   428 		// The image sub-sizes are created during wp_generate_attachment_metadata().
   433 		/*
   429 		// This is generally slow and may cause timeouts or out of memory errors.
   434 		 * The image sub-sizes are created during wp_generate_attachment_metadata().
       
   435 		 * This is generally slow and may cause timeouts or out of memory errors.
       
   436 		 */
   430 		wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) );
   437 		wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) );
   431 	}
   438 	}
   432 
   439 
   433 	return $attachment_id;
   440 	return $attachment_id;
   434 }
   441 }
   518  *
   525  *
   519  * @since 2.5.0
   526  * @since 2.5.0
   520  * @since 5.3.0 Formalized the existing and already documented `...$args` parameter
   527  * @since 5.3.0 Formalized the existing and already documented `...$args` parameter
   521  *              by adding it to the function signature.
   528  *              by adding it to the function signature.
   522  *
   529  *
   523  * @global int $body_id
   530  * @global string $body_id
   524  *
   531  *
   525  * @param callable $content_func Function that outputs the content.
   532  * @param callable $content_func Function that outputs the content.
   526  * @param mixed    ...$args      Optional additional parameters to pass to the callback function when it's called.
   533  * @param mixed    ...$args      Optional additional parameters to pass to the callback function when it's called.
   527  */
   534  */
   528 function wp_iframe( $content_func, ...$args ) {
   535 function wp_iframe( $content_func, ...$args ) {
       
   536 	global $body_id;
       
   537 
   529 	_wp_admin_html_begin();
   538 	_wp_admin_html_begin();
   530 	?>
   539 	?>
   531 	<title><?php bloginfo( 'name' ); ?> &rsaquo; <?php _e( 'Uploads' ); ?> &#8212; <?php _e( 'WordPress' ); ?></title>
   540 	<title><?php bloginfo( 'name' ); ?> &rsaquo; <?php _e( 'Uploads' ); ?> &#8212; <?php _e( 'WordPress' ); ?></title>
   532 	<?php
   541 	<?php
   533 
   542 
   534 	wp_enqueue_style( 'colors' );
   543 	wp_enqueue_style( 'colors' );
   535 	// Check callback name for 'media'.
   544 	// Check callback name for 'media'.
   536 	if (
   545 	if (
   537 		( is_array( $content_func ) && ! empty( $content_func[1] ) && 0 === strpos( (string) $content_func[1], 'media' ) ) ||
   546 		( is_array( $content_func ) && ! empty( $content_func[1] ) && str_starts_with( (string) $content_func[1], 'media' ) ) ||
   538 		( ! is_array( $content_func ) && 0 === strpos( $content_func, 'media' ) )
   547 		( ! is_array( $content_func ) && str_starts_with( $content_func, 'media' ) )
   539 	) {
   548 	) {
   540 		wp_enqueue_style( 'deprecated-media' );
   549 		wp_enqueue_style( 'deprecated-media' );
   541 	}
   550 	}
   542 
   551 
   543 	?>
   552 	?>
   594 		do_action( "admin_head_{$content_func}" );
   603 		do_action( "admin_head_{$content_func}" );
   595 	}
   604 	}
   596 
   605 
   597 	$body_id_attr = '';
   606 	$body_id_attr = '';
   598 
   607 
   599 	if ( isset( $GLOBALS['body_id'] ) ) {
   608 	if ( isset( $body_id ) ) {
   600 		$body_id_attr = ' id="' . $GLOBALS['body_id'] . '"';
   609 		$body_id_attr = ' id="' . $body_id . '"';
   601 	}
   610 	}
   602 
   611 
   603 	?>
   612 	?>
   604 	</head>
   613 	</head>
   605 	<body<?php echo $body_id_attr; ?> class="wp-core-ui no-js">
   614 	<body<?php echo $body_id_attr; ?> class="wp-core-ui no-js">
   629  *
   638  *
   630  * @param string $editor_id
   639  * @param string $editor_id
   631  */
   640  */
   632 function media_buttons( $editor_id = 'content' ) {
   641 function media_buttons( $editor_id = 'content' ) {
   633 	static $instance = 0;
   642 	static $instance = 0;
   634 	$instance++;
   643 	++$instance;
   635 
   644 
   636 	$post = get_post();
   645 	$post = get_post();
   637 
   646 
   638 	if ( ! $post && ! empty( $GLOBALS['post_ID'] ) ) {
   647 	if ( ! $post && ! empty( $GLOBALS['post_ID'] ) ) {
   639 		$post = $GLOBALS['post_ID'];
   648 		$post = $GLOBALS['post_ID'];
   672 		echo $legacy_filter;
   681 		echo $legacy_filter;
   673 	}
   682 	}
   674 }
   683 }
   675 
   684 
   676 /**
   685 /**
       
   686  * Retrieves the upload iframe source URL.
       
   687  *
       
   688  * @since 3.0.0
       
   689  *
   677  * @global int $post_ID
   690  * @global int $post_ID
   678  * @param string $type
   691  *
   679  * @param int    $post_id
   692  * @param string $type    Media type.
   680  * @param string $tab
   693  * @param int    $post_id Post ID.
   681  * @return string
   694  * @param string $tab     Media upload tab.
       
   695  * @return string Upload iframe source URL.
   682  */
   696  */
   683 function get_upload_iframe_src( $type = null, $post_id = null, $tab = null ) {
   697 function get_upload_iframe_src( $type = null, $post_id = null, $tab = null ) {
   684 	global $post_ID;
   698 	global $post_ID;
   685 
   699 
   686 	if ( empty( $post_id ) ) {
   700 	if ( empty( $post_id ) ) {
   821 		$html       = isset( $attachment['post_title'] ) ? $attachment['post_title'] : '';
   835 		$html       = isset( $attachment['post_title'] ) ? $attachment['post_title'] : '';
   822 
   836 
   823 		if ( ! empty( $attachment['url'] ) ) {
   837 		if ( ! empty( $attachment['url'] ) ) {
   824 			$rel = '';
   838 			$rel = '';
   825 
   839 
   826 			if ( strpos( $attachment['url'], 'attachment_id' ) || get_attachment_link( $send_id ) == $attachment['url'] ) {
   840 			if ( str_contains( $attachment['url'], 'attachment_id' ) || get_attachment_link( $send_id ) === $attachment['url'] ) {
   827 				$rel = " rel='attachment wp-att-" . esc_attr( $send_id ) . "'";
   841 				$rel = " rel='attachment wp-att-" . esc_attr( $send_id ) . "'";
   828 			}
   842 			}
   829 
   843 
   830 			$html = "<a href='{$attachment['url']}'$rel>$html</a>";
   844 			$html = "<a href='{$attachment['url']}'$rel>$html</a>";
   831 		}
   845 		}
   915 			 *
   929 			 *
   916 			 * @param string $html  HTML markup sent to the editor.
   930 			 * @param string $html  HTML markup sent to the editor.
   917 			 * @param string $src   Media source URL.
   931 			 * @param string $src   Media source URL.
   918 			 * @param string $title Media title.
   932 			 * @param string $title Media title.
   919 			 */
   933 			 */
   920 			$html = apply_filters( "{$type}_send_to_editor_url", $html, esc_url_raw( $src ), $title );
   934 			$html = apply_filters( "{$type}_send_to_editor_url", $html, sanitize_url( $src ), $title );
   921 		} else {
   935 		} else {
   922 			$align = '';
   936 			$align = '';
   923 			$alt   = esc_attr( wp_unslash( $_POST['alt'] ) );
   937 			$alt   = esc_attr( wp_unslash( $_POST['alt'] ) );
   924 
   938 
   925 			if ( isset( $_POST['align'] ) ) {
   939 			if ( isset( $_POST['align'] ) ) {
   940 			 * @param string $src   Image source URL.
   954 			 * @param string $src   Image source URL.
   941 			 * @param string $alt   Image alternate, or alt, text.
   955 			 * @param string $alt   Image alternate, or alt, text.
   942 			 * @param string $align The image alignment. Default 'alignnone'. Possible values include
   956 			 * @param string $align The image alignment. Default 'alignnone'. Possible values include
   943 			 *                      'alignleft', 'aligncenter', 'alignright', 'alignnone'.
   957 			 *                      'alignleft', 'aligncenter', 'alignright', 'alignnone'.
   944 			 */
   958 			 */
   945 			$html = apply_filters( 'image_send_to_editor_url', $html, esc_url_raw( $src ), $alt, $align );
   959 			$html = apply_filters( 'image_send_to_editor_url', $html, sanitize_url( $src ), $alt, $align );
   946 		}
   960 		}
   947 
   961 
   948 		return media_send_to_editor( $html );
   962 		return media_send_to_editor( $html );
   949 	}
   963 	}
   950 
   964 
   986  * @since 4.2.0 Introduced the `$return_type` parameter.
  1000  * @since 4.2.0 Introduced the `$return_type` parameter.
   987  * @since 4.8.0 Introduced the 'id' option for the `$return_type` parameter.
  1001  * @since 4.8.0 Introduced the 'id' option for the `$return_type` parameter.
   988  * @since 5.3.0 The `$post_id` parameter was made optional.
  1002  * @since 5.3.0 The `$post_id` parameter was made optional.
   989  * @since 5.4.0 The original URL of the attachment is stored in the `_source_url`
  1003  * @since 5.4.0 The original URL of the attachment is stored in the `_source_url`
   990  *              post meta value.
  1004  *              post meta value.
       
  1005  * @since 5.8.0 Added 'webp' to the default list of allowed file extensions.
   991  *
  1006  *
   992  * @param string $file        The URL of the image to download.
  1007  * @param string $file        The URL of the image to download.
   993  * @param int    $post_id     Optional. The post ID the media is to be associated with.
  1008  * @param int    $post_id     Optional. The post ID the media is to be associated with.
   994  * @param string $desc        Optional. Description of the image.
  1009  * @param string $desc        Optional. Description of the image.
   995  * @param string $return_type Optional. Accepts 'html' (image tag html) or 'src' (URL),
  1010  * @param string $return_type Optional. Accepts 'html' (image tag html) or 'src' (URL),
  1010 		 *  - `jpg`
  1025 		 *  - `jpg`
  1011 		 *  - `jpeg`
  1026 		 *  - `jpeg`
  1012 		 *  - `jpe`
  1027 		 *  - `jpe`
  1013 		 *  - `png`
  1028 		 *  - `png`
  1014 		 *  - `gif`
  1029 		 *  - `gif`
       
  1030 		 *  - `webp`
  1015 		 *
  1031 		 *
  1016 		 * @since 5.6.0
  1032 		 * @since 5.6.0
       
  1033 		 * @since 5.8.0 Added 'webp' to the default list of allowed file extensions.
  1017 		 *
  1034 		 *
  1018 		 * @param string[] $allowed_extensions Array of allowed file extensions.
  1035 		 * @param string[] $allowed_extensions Array of allowed file extensions.
  1019 		 * @param string   $file               The URL of the image to download.
  1036 		 * @param string   $file               The URL of the image to download.
  1020 		 */
  1037 		 */
  1021 		$allowed_extensions = apply_filters( 'image_sideload_extensions', $allowed_extensions, $file );
  1038 		$allowed_extensions = apply_filters( 'image_sideload_extensions', $allowed_extensions, $file );
  1148 
  1165 
  1149 	if ( ! array_key_exists( (string) $checked, $alignments ) ) {
  1166 	if ( ! array_key_exists( (string) $checked, $alignments ) ) {
  1150 		$checked = 'none';
  1167 		$checked = 'none';
  1151 	}
  1168 	}
  1152 
  1169 
  1153 	$out = array();
  1170 	$output = array();
  1154 
  1171 
  1155 	foreach ( $alignments as $name => $label ) {
  1172 	foreach ( $alignments as $name => $label ) {
  1156 		$name  = esc_attr( $name );
  1173 		$name     = esc_attr( $name );
  1157 		$out[] = "<input type='radio' name='attachments[{$post->ID}][align]' id='image-align-{$name}-{$post->ID}' value='$name'" .
  1174 		$output[] = "<input type='radio' name='attachments[{$post->ID}][align]' id='image-align-{$name}-{$post->ID}' value='$name'" .
  1158 			( $checked == $name ? " checked='checked'" : '' ) .
  1175 			( $checked == $name ? " checked='checked'" : '' ) .
  1159 			" /><label for='image-align-{$name}-{$post->ID}' class='align image-align-{$name}-label'>$label</label>";
  1176 			" /><label for='image-align-{$name}-{$post->ID}' class='align image-align-{$name}-label'>$label</label>";
  1160 	}
  1177 	}
  1161 
  1178 
  1162 	return implode( "\n", $out );
  1179 	return implode( "\n", $output );
  1163 }
  1180 }
  1164 
  1181 
  1165 /**
  1182 /**
  1166  * Retrieves HTML for the size radio buttons with the specified one checked.
  1183  * Retrieves HTML for the size radio buttons with the specified one checked.
  1167  *
  1184  *
  1192 
  1209 
  1193 	if ( empty( $check ) ) {
  1210 	if ( empty( $check ) ) {
  1194 		$check = get_user_setting( 'imgsize', 'medium' );
  1211 		$check = get_user_setting( 'imgsize', 'medium' );
  1195 	}
  1212 	}
  1196 
  1213 
  1197 	$out = array();
  1214 	$output = array();
  1198 
  1215 
  1199 	foreach ( $size_names as $size => $label ) {
  1216 	foreach ( $size_names as $size => $label ) {
  1200 		$downsize = image_downsize( $post->ID, $size );
  1217 		$downsize = image_downsize( $post->ID, $size );
  1201 		$checked  = '';
  1218 		$checked  = '';
  1202 
  1219 
  1228 		if ( $enabled ) {
  1245 		if ( $enabled ) {
  1229 			$html .= " <label for='{$css_id}' class='help'>" . sprintf( '(%d&nbsp;&times;&nbsp;%d)', $downsize[1], $downsize[2] ) . '</label>';
  1246 			$html .= " <label for='{$css_id}' class='help'>" . sprintf( '(%d&nbsp;&times;&nbsp;%d)', $downsize[1], $downsize[2] ) . '</label>';
  1230 		}
  1247 		}
  1231 		$html .= '</div>';
  1248 		$html .= '</div>';
  1232 
  1249 
  1233 		$out[] = $html;
  1250 		$output[] = $html;
  1234 	}
  1251 	}
  1235 
  1252 
  1236 	return array(
  1253 	return array(
  1237 		'label' => __( 'Size' ),
  1254 		'label' => __( 'Size' ),
  1238 		'input' => 'html',
  1255 		'input' => 'html',
  1239 		'html'  => implode( "\n", $out ),
  1256 		'html'  => implode( "\n", $output ),
  1240 	);
  1257 	);
  1241 }
  1258 }
  1242 
  1259 
  1243 /**
  1260 /**
  1244  * Retrieves HTML for the Link URL buttons with the default link type as specified.
  1261  * Retrieves HTML for the Link URL buttons with the default link type as specified.
  1267 	}
  1284 	}
  1268 
  1285 
  1269 	return "
  1286 	return "
  1270 	<input type='text' class='text urlfield' name='attachments[$post->ID][url]' value='" . esc_attr( $url ) . "' /><br />
  1287 	<input type='text' class='text urlfield' name='attachments[$post->ID][url]' value='" . esc_attr( $url ) . "' /><br />
  1271 	<button type='button' class='button urlnone' data-link-url=''>" . __( 'None' ) . "</button>
  1288 	<button type='button' class='button urlnone' data-link-url=''>" . __( 'None' ) . "</button>
  1272 	<button type='button' class='button urlfile' data-link-url='" . esc_attr( $file ) . "'>" . __( 'File URL' ) . "</button>
  1289 	<button type='button' class='button urlfile' data-link-url='" . esc_url( $file ) . "'>" . __( 'File URL' ) . "</button>
  1273 	<button type='button' class='button urlpost' data-link-url='" . esc_attr( $link ) . "'>" . __( 'Attachment Post URL' ) . '</button>
  1290 	<button type='button' class='button urlpost' data-link-url='" . esc_url( $link ) . "'>" . __( 'Attachment Post URL' ) . '</button>
  1274 ';
  1291 ';
  1275 }
  1292 }
  1276 
  1293 
  1277 /**
  1294 /**
  1278  * Outputs a textarea element for inputting an attachment caption.
  1295  * Outputs a textarea element for inputting an attachment caption.
  1341  * @return string
  1358  * @return string
  1342  */
  1359  */
  1343 function image_media_send_to_editor( $html, $attachment_id, $attachment ) {
  1360 function image_media_send_to_editor( $html, $attachment_id, $attachment ) {
  1344 	$post = get_post( $attachment_id );
  1361 	$post = get_post( $attachment_id );
  1345 
  1362 
  1346 	if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) {
  1363 	if ( str_starts_with( $post->post_mime_type, 'image' ) ) {
  1347 		$url   = $attachment['url'];
  1364 		$url   = $attachment['url'];
  1348 		$align = ! empty( $attachment['align'] ) ? $attachment['align'] : 'none';
  1365 		$align = ! empty( $attachment['align'] ) ? $attachment['align'] : 'none';
  1349 		$size  = ! empty( $attachment['image-size'] ) ? $attachment['image-size'] : 'medium';
  1366 		$size  = ! empty( $attachment['image-size'] ) ? $attachment['image-size'] : 'medium';
  1350 		$alt   = ! empty( $attachment['image_alt'] ) ? $attachment['image_alt'] : '';
  1367 		$alt   = ! empty( $attachment['image_alt'] ) ? $attachment['image_alt'] : '';
  1351 		$rel   = ( strpos( $url, 'attachment_id' ) || get_attachment_link( $attachment_id ) === $url );
  1368 		$rel   = ( str_contains( $url, 'attachment_id' ) || get_attachment_link( $attachment_id ) === $url );
  1352 
  1369 
  1353 		return get_image_send_to_editor( $attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size, $alt );
  1370 		return get_image_send_to_editor( $attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size, $alt );
  1354 	}
  1371 	}
  1355 
  1372 
  1356 	return $html;
  1373 	return $html;
  1452 	 * foreach ( (array) $things as $thing )
  1469 	 * foreach ( (array) $things as $thing )
  1453 	 */
  1470 	 */
  1454 	$form_fields = array_merge_recursive( $form_fields, (array) $errors );
  1471 	$form_fields = array_merge_recursive( $form_fields, (array) $errors );
  1455 
  1472 
  1456 	// This was formerly in image_attachment_fields_to_edit().
  1473 	// This was formerly in image_attachment_fields_to_edit().
  1457 	if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) {
  1474 	if ( str_starts_with( $post->post_mime_type, 'image' ) ) {
  1458 		$alt = get_post_meta( $post->ID, '_wp_attachment_image_alt', true );
  1475 		$alt = get_post_meta( $post->ID, '_wp_attachment_image_alt', true );
  1459 
  1476 
  1460 		if ( empty( $alt ) ) {
  1477 		if ( empty( $alt ) ) {
  1461 			$alt = '';
  1478 			$alt = '';
  1462 		}
  1479 		}
  1645 
  1662 
  1646 	$media_dims = '';
  1663 	$media_dims = '';
  1647 	$meta       = wp_get_attachment_metadata( $post->ID );
  1664 	$meta       = wp_get_attachment_metadata( $post->ID );
  1648 
  1665 
  1649 	if ( isset( $meta['width'], $meta['height'] ) ) {
  1666 	if ( isset( $meta['width'], $meta['height'] ) ) {
  1650 		$media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']}&nbsp;&times;&nbsp;{$meta['height']}</span> ";
  1667 		/* translators: 1: A number of pixels wide, 2: A number of pixels tall. */
       
  1668 		$media_dims .= "<span id='media-dims-$post->ID'>" . sprintf( __( '%1$s by %2$s pixels' ), $meta['width'], $meta['height'] ) . '</span>';
  1651 	}
  1669 	}
  1652 
  1670 
  1653 	/**
  1671 	/**
  1654 	 * Filters the media metadata.
  1672 	 * Filters the media metadata.
  1655 	 *
  1673 	 *
  1696 		</thead>
  1714 		</thead>
  1697 		<tbody>
  1715 		<tbody>
  1698 		<tr><td colspan='2' class='imgedit-response' id='imgedit-response-$post->ID'></td></tr>\n
  1716 		<tr><td colspan='2' class='imgedit-response' id='imgedit-response-$post->ID'></td></tr>\n
  1699 		<tr><td style='display:none' colspan='2' class='image-editor' id='image-editor-$post->ID'></td></tr>\n
  1717 		<tr><td style='display:none' colspan='2' class='image-editor' id='image-editor-$post->ID'></td></tr>\n
  1700 		<tr><td colspan='2'><p class='media-types media-types-required-info'>" .
  1718 		<tr><td colspan='2'><p class='media-types media-types-required-info'>" .
  1701 			/* translators: %s: Asterisk symbol (*). */
  1719 			wp_required_field_message() .
  1702 			sprintf( __( 'Required fields are marked %s' ), '<span class="required">*</span>' ) .
       
  1703 		"</p></td></tr>\n";
  1720 		"</p></td></tr>\n";
  1704 
  1721 
  1705 	$defaults = array(
  1722 	$defaults = array(
  1706 		'input'      => 'text',
  1723 		'input'      => 'text',
  1707 		'required'   => false,
  1724 		'required'   => false,
  1777 		if ( 'hidden' === $field['input'] ) {
  1794 		if ( 'hidden' === $field['input'] ) {
  1778 			$hidden_fields[ $name ] = $field['value'];
  1795 			$hidden_fields[ $name ] = $field['value'];
  1779 			continue;
  1796 			continue;
  1780 		}
  1797 		}
  1781 
  1798 
  1782 		$required      = $field['required'] ? '<span class="required">*</span>' : '';
  1799 		$required      = $field['required'] ? ' ' . wp_required_field_indicator() : '';
  1783 		$required_attr = $field['required'] ? ' required' : '';
  1800 		$required_attr = $field['required'] ? ' required' : '';
  1784 		$class         = $id;
  1801 		$class         = $id;
  1785 		$class        .= $field['required'] ? ' form-required' : '';
  1802 		$class        .= $field['required'] ? ' form-required' : '';
  1786 
  1803 
  1787 		$item .= "\t\t<tr class='$class'>\n\t\t\t<th scope='row' class='label'><label for='$name'><span class='alignleft'>{$field['label']}{$required}</span><br class='clear' /></label></th>\n\t\t\t<td class='field'>";
  1804 		$item .= "\t\t<tr class='$class'>\n\t\t\t<th scope='row' class='label'><label for='$name'><span class='alignleft'>{$field['label']}{$required}</span><br class='clear' /></label></th>\n\t\t\t<td class='field'>";
  1968 			$hidden_fields[ $name ] = $field['value'];
  1985 			$hidden_fields[ $name ] = $field['value'];
  1969 			continue;
  1986 			continue;
  1970 		}
  1987 		}
  1971 
  1988 
  1972 		$readonly      = ! $user_can_edit && ! empty( $field['taxonomy'] ) ? " readonly='readonly' " : '';
  1989 		$readonly      = ! $user_can_edit && ! empty( $field['taxonomy'] ) ? " readonly='readonly' " : '';
  1973 		$required      = $field['required'] ? '<span class="required">*</span>' : '';
  1990 		$required      = $field['required'] ? ' ' . wp_required_field_indicator() : '';
  1974 		$required_attr = $field['required'] ? ' required' : '';
  1991 		$required_attr = $field['required'] ? ' required' : '';
  1975 		$class         = 'compat-field-' . $id;
  1992 		$class         = 'compat-field-' . $id;
  1976 		$class        .= $field['required'] ? ' form-required' : '';
  1993 		$class        .= $field['required'] ? ' form-required' : '';
  1977 
  1994 
  1978 		$item .= "\t\t<tr class='$class'>";
  1995 		$item .= "\t\t<tr class='$class'>";
  2024 		$item .= "\t\t<tr class='final'><td colspan='2'>{$form_fields['_final']}</td></tr>\n";
  2041 		$item .= "\t\t<tr class='final'><td colspan='2'>{$form_fields['_final']}</td></tr>\n";
  2025 	}
  2042 	}
  2026 
  2043 
  2027 	if ( $item ) {
  2044 	if ( $item ) {
  2028 		$item = '<p class="media-types media-types-required-info">' .
  2045 		$item = '<p class="media-types media-types-required-info">' .
  2029 			/* translators: %s: Asterisk symbol (*). */
  2046 			wp_required_field_message() .
  2030 			sprintf( __( 'Required fields are marked %s' ), '<span class="required">*</span>' ) .
       
  2031 			'</p>' .
  2047 			'</p>' .
  2032 			'<table class="compat-attachment-fields">' . $item . '</table>';
  2048 			'<table class="compat-attachment-fields">' . $item . '</table>';
  2033 	}
  2049 	}
  2034 
  2050 
  2035 	foreach ( $hidden_fields as $hidden_field => $value ) {
  2051 	foreach ( $hidden_fields as $hidden_field => $value ) {
  2068  *
  2084  *
  2069  * @since 2.5.0
  2085  * @since 2.5.0
  2070  *
  2086  *
  2071  * @global string $type
  2087  * @global string $type
  2072  * @global string $tab
  2088  * @global string $tab
  2073  * @global bool   $is_IE
       
  2074  * @global bool   $is_opera
       
  2075  *
  2089  *
  2076  * @param array $errors
  2090  * @param array $errors
  2077  */
  2091  */
  2078 function media_upload_form( $errors = null ) {
  2092 function media_upload_form( $errors = null ) {
  2079 	global $type, $tab, $is_IE, $is_opera;
  2093 	global $type, $tab;
  2080 
  2094 
  2081 	if ( ! _device_can_upload() ) {
  2095 	if ( ! _device_can_upload() ) {
  2082 		echo '<p>' . sprintf(
  2096 		echo '<p>' . sprintf(
  2083 			/* translators: %s: https://apps.wordpress.org/ */
  2097 			/* translators: %s: https://apps.wordpress.org/ */
  2084 			__( 'The web browser on your device cannot be used to upload files. You may be able to use the <a href="%s">native app for your device</a> instead.' ),
  2098 			__( 'The web browser on your device cannot be used to upload files. You may be able to use the <a href="%s">native app for your device</a> instead.' ),
  2172 	 * but iOS 7.x has a bug that prevents uploading of videos when enabled.
  2186 	 * but iOS 7.x has a bug that prevents uploading of videos when enabled.
  2173 	 * See #29602.
  2187 	 * See #29602.
  2174 	 */
  2188 	 */
  2175 	if (
  2189 	if (
  2176 		wp_is_mobile() &&
  2190 		wp_is_mobile() &&
  2177 		strpos( $_SERVER['HTTP_USER_AGENT'], 'OS 7_' ) !== false &&
  2191 		str_contains( $_SERVER['HTTP_USER_AGENT'], 'OS 7_' ) &&
  2178 		strpos( $_SERVER['HTTP_USER_AGENT'], 'like Mac OS X' ) !== false
  2192 		str_contains( $_SERVER['HTTP_USER_AGENT'], 'like Mac OS X' )
  2179 	) {
  2193 	) {
  2180 		$plupload_init['multi_selection'] = false;
  2194 		$plupload_init['multi_selection'] = false;
  2181 	}
  2195 	}
  2182 
  2196 
  2183 	// Check if WebP images can be edited.
  2197 	// Check if WebP images can be edited.
  2184 	if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/webp' ) ) ) {
  2198 	if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/webp' ) ) ) {
  2185 		$plupload_init['webp_upload_error'] = true;
  2199 		$plupload_init['webp_upload_error'] = true;
       
  2200 	}
       
  2201 
       
  2202 	// Check if AVIF images can be edited.
       
  2203 	if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/avif' ) ) ) {
       
  2204 		$plupload_init['avif_upload_error'] = true;
  2186 	}
  2205 	}
  2187 
  2206 
  2188 	/**
  2207 	/**
  2189 	 * Filters the default Plupload settings.
  2208 	 * Filters the default Plupload settings.
  2190 	 *
  2209 	 *
  2253 	 */
  2272 	 */
  2254 	do_action( 'pre-html-upload-ui' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
  2273 	do_action( 'pre-html-upload-ui' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
  2255 
  2274 
  2256 	?>
  2275 	?>
  2257 	<p id="async-upload-wrap">
  2276 	<p id="async-upload-wrap">
  2258 		<label class="screen-reader-text" for="async-upload"><?php _e( 'Upload' ); ?></label>
  2277 		<label class="screen-reader-text" for="async-upload">
       
  2278 			<?php
       
  2279 			/* translators: Hidden accessibility text. */
       
  2280 			_e( 'Upload' );
       
  2281 			?>
       
  2282 		</label>
  2259 		<input type="file" name="async-upload" id="async-upload" />
  2283 		<input type="file" name="async-upload" id="async-upload" />
  2260 		<?php submit_button( __( 'Upload' ), 'primary', 'html-upload', false ); ?>
  2284 		<?php submit_button( __( 'Upload' ), 'primary', 'html-upload', false ); ?>
  2261 		<a href="#" onclick="try{top.tb_remove();}catch(e){}; return false;"><?php _e( 'Cancel' ); ?></a>
  2285 		<a href="#" onclick="try{top.tb_remove();}catch(e){}; return false;"><?php _e( 'Cancel' ); ?></a>
  2262 	</p>
  2286 	</p>
  2263 	<div class="clear"></div>
  2287 	<div class="clear"></div>
  2721 	<input type="hidden" name="post_id" value="<?php echo (int) $post_id; ?>" />
  2745 	<input type="hidden" name="post_id" value="<?php echo (int) $post_id; ?>" />
  2722 	<input type="hidden" name="post_mime_type" value="<?php echo isset( $_GET['post_mime_type'] ) ? esc_attr( $_GET['post_mime_type'] ) : ''; ?>" />
  2746 	<input type="hidden" name="post_mime_type" value="<?php echo isset( $_GET['post_mime_type'] ) ? esc_attr( $_GET['post_mime_type'] ) : ''; ?>" />
  2723 	<input type="hidden" name="context" value="<?php echo isset( $_GET['context'] ) ? esc_attr( $_GET['context'] ) : ''; ?>" />
  2747 	<input type="hidden" name="context" value="<?php echo isset( $_GET['context'] ) ? esc_attr( $_GET['context'] ) : ''; ?>" />
  2724 
  2748 
  2725 	<p id="media-search" class="search-box">
  2749 	<p id="media-search" class="search-box">
  2726 		<label class="screen-reader-text" for="media-search-input"><?php _e( 'Search Media' ); ?>:</label>
  2750 		<label class="screen-reader-text" for="media-search-input">
       
  2751 			<?php
       
  2752 			/* translators: Hidden accessibility text. */
       
  2753 			_e( 'Search Media:' );
       
  2754 			?>
       
  2755 		</label>
  2727 		<input type="search" id="media-search-input" name="s" value="<?php the_search_query(); ?>" />
  2756 		<input type="search" id="media-search-input" name="s" value="<?php the_search_query(); ?>" />
  2728 		<?php submit_button( __( 'Search Media' ), '', '', false ); ?>
  2757 		<?php submit_button( __( 'Search Media' ), '', '', false ); ?>
  2729 	</p>
  2758 	</p>
  2730 
  2759 
  2731 	<ul class="subsubsub">
  2760 	<ul class="subsubsub">
  2802 			array(
  2831 			array(
  2803 				'base'      => add_query_arg( 'paged', '%#%' ),
  2832 				'base'      => add_query_arg( 'paged', '%#%' ),
  2804 				'format'    => '',
  2833 				'format'    => '',
  2805 				'prev_text' => __( '&laquo;' ),
  2834 				'prev_text' => __( '&laquo;' ),
  2806 				'next_text' => __( '&raquo;' ),
  2835 				'next_text' => __( '&raquo;' ),
  2807 				'total'     => ceil( $wp_query->found_posts / 10 ),
  2836 				'total'     => (int) ceil( $wp_query->found_posts / 10 ),
  2808 				'current'   => $q['paged'],
  2837 				'current'   => $q['paged'],
  2809 			)
  2838 			)
  2810 		);
  2839 		);
  2811 
  2840 
  2812 		if ( $page_links ) {
  2841 		if ( $page_links ) {
  2922 	}
  2951 	}
  2923 
  2952 
  2924 	return '
  2953 	return '
  2925 	<p class="media-types"><label><input type="radio" name="media_type" value="image" id="image-only"' . checked( 'image-only', $view, false ) . ' /> ' . __( 'Image' ) . '</label> &nbsp; &nbsp; <label><input type="radio" name="media_type" value="generic" id="not-image"' . checked( 'not-image', $view, false ) . ' /> ' . __( 'Audio, Video, or Other File' ) . '</label></p>
  2954 	<p class="media-types"><label><input type="radio" name="media_type" value="image" id="image-only"' . checked( 'image-only', $view, false ) . ' /> ' . __( 'Image' ) . '</label> &nbsp; &nbsp; <label><input type="radio" name="media_type" value="generic" id="not-image"' . checked( 'not-image', $view, false ) . ' /> ' . __( 'Audio, Video, or Other File' ) . '</label></p>
  2926 	<p class="media-types media-types-required-info">' .
  2955 	<p class="media-types media-types-required-info">' .
  2927 		/* translators: %s: Asterisk symbol (*). */
  2956 		wp_required_field_message() .
  2928 		sprintf( __( 'Required fields are marked %s' ), '<span class="required">*</span>' ) .
       
  2929 	'</p>
  2957 	'</p>
  2930 	<table class="describe ' . $table_class . '"><tbody>
  2958 	<table class="describe ' . $table_class . '"><tbody>
  2931 		<tr>
  2959 		<tr>
  2932 			<th scope="row" class="label" style="width:130px;">
  2960 			<th scope="row" class="label" style="width:130px;">
  2933 				<label for="src"><span class="alignleft">' . __( 'URL' ) . '</span> <span class="required">*</span></label>
  2961 				<label for="src"><span class="alignleft">' . __( 'URL' ) . '</span> ' . wp_required_field_indicator() . '</label>
  2934 				<span class="alignright" id="status_img"></span>
  2962 				<span class="alignright" id="status_img"></span>
  2935 			</th>
  2963 			</th>
  2936 			<td class="field"><input id="src" name="src" value="" type="text" required onblur="addExtImage.getImageData()" /></td>
  2964 			<td class="field"><input id="src" name="src" value="" type="text" required onblur="addExtImage.getImageData()" /></td>
  2937 		</tr>
  2965 		</tr>
  2938 
  2966 
  2939 		<tr>
  2967 		<tr>
  2940 			<th scope="row" class="label">
  2968 			<th scope="row" class="label">
  2941 				<label for="title"><span class="alignleft">' . __( 'Title' ) . '</span> <span class="required">*</span></label>
  2969 				<label for="title"><span class="alignleft">' . __( 'Title' ) . '</span> ' . wp_required_field_indicator() . '</label>
  2942 			</th>
  2970 			</th>
  2943 			<td class="field"><input id="title" name="title" value="" type="text" required /></td>
  2971 			<td class="field"><input id="title" name="title" value="" type="text" required /></td>
  2944 		</tr>
  2972 		</tr>
  2945 
  2973 
  2946 		<tr class="not-image"><td></td><td><p class="help">' . __( 'Link text, e.g. &#8220;Ransom Demands (PDF)&#8221;' ) . '</p></td></tr>
  2974 		<tr class="not-image"><td></td><td><p class="help">' . __( 'Link text, e.g. &#8220;Ransom Demands (PDF)&#8221;' ) . '</p></td></tr>
  2947 
  2975 
  2948 		<tr class="image-only">
  2976 		<tr class="image-only">
  2949 			<th scope="row" class="label">
  2977 			<th scope="row" class="label">
  2950 				<label for="alt"><span class="alignleft">' . __( 'Alternative Text' ) . '</span></label>
  2978 				<label for="alt"><span class="alignleft">' . __( 'Alternative Text' ) . '</span> ' . wp_required_field_indicator() . '</label>
  2951 			</th>
  2979 			</th>
  2952 			<td class="field"><input id="alt" name="alt" value="" type="text" required />
  2980 			<td class="field"><input id="alt" name="alt" value="" type="text" required />
  2953 			<p class="help">' . __( 'Alt text for the image, e.g. &#8220;The Mona Lisa&#8221;' ) . '</p></td>
  2981 			<p class="help">' . __( 'Alt text for the image, e.g. &#8220;The Mona Lisa&#8221;' ) . '</p></td>
  2954 		</tr>
  2982 		</tr>
  2955 		' . $caption . '
  2983 		' . $caption . '
  3200 	endif;
  3228 	endif;
  3201 
  3229 
  3202 	?>
  3230 	?>
  3203 	</div>
  3231 	</div>
  3204 	<div class="wp_attachment_details edit-form-section">
  3232 	<div class="wp_attachment_details edit-form-section">
  3205 	<?php if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) : ?>
  3233 	<?php if ( str_starts_with( $post->post_mime_type, 'image' ) ) : ?>
  3206 		<p class="attachment-alt-text">
  3234 		<p class="attachment-alt-text">
  3207 			<label for="attachment_alt"><strong><?php _e( 'Alternative Text' ); ?></strong></label><br />
  3235 			<label for="attachment_alt"><strong><?php _e( 'Alternative Text' ); ?></strong></label><br />
  3208 			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" aria-describedby="alt-text-description" value="<?php echo esc_attr( $alt_text ); ?>" />
  3236 			<textarea class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" aria-describedby="alt-text-description"><?php echo esc_attr( $alt_text ); ?></textarea>
  3209 		</p>
  3237 		</p>
  3210 		<p class="attachment-alt-text-description" id="alt-text-description">
  3238 		<p class="attachment-alt-text-description" id="alt-text-description">
  3211 		<?php
  3239 		<?php
  3212 
  3240 
  3213 		printf(
  3241 		printf(
  3214 			/* translators: 1: Link to tutorial, 2: Additional link attributes, 3: Accessibility text. */
  3242 			/* translators: 1: Link to tutorial, 2: Additional link attributes, 3: Accessibility text. */
  3215 			__( '<a href="%1$s" %2$s>Learn how to describe the purpose of the image%3$s</a>. Leave empty if the image is purely decorative.' ),
  3243 			__( '<a href="%1$s" %2$s>Learn how to describe the purpose of the image%3$s</a>. Leave empty if the image is purely decorative.' ),
  3216 			esc_url( 'https://www.w3.org/WAI/tutorials/images/decision-tree' ),
  3244 			/* translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations. */
       
  3245 			esc_url( __( 'https://www.w3.org/WAI/tutorials/images/decision-tree/' ) ),
  3217 			'target="_blank" rel="noopener"',
  3246 			'target="_blank" rel="noopener"',
  3218 			sprintf(
  3247 			sprintf(
  3219 				'<span class="screen-reader-text"> %s</span>',
  3248 				'<span class="screen-reader-text"> %s</span>',
  3220 				/* translators: Accessibility text. */
  3249 				/* translators: Hidden accessibility text. */
  3221 				__( '(opens in a new tab)' )
  3250 				__( '(opens in a new tab)' )
  3222 			)
  3251 			)
  3223 		);
  3252 		);
  3224 
  3253 
  3225 		?>
  3254 		?>
  3236 	$quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' );
  3265 	$quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' );
  3237 	$editor_args        = array(
  3266 	$editor_args        = array(
  3238 		'textarea_name' => 'content',
  3267 		'textarea_name' => 'content',
  3239 		'textarea_rows' => 5,
  3268 		'textarea_rows' => 5,
  3240 		'media_buttons' => false,
  3269 		'media_buttons' => false,
  3241 		'tinymce'       => false,
  3270 		/**
       
  3271 		 * Filters the TinyMCE argument for the media description field on the attachment details screen.
       
  3272 		 *
       
  3273 		 * @since 6.6.0
       
  3274 		 *
       
  3275 		 * @param bool $tinymce Whether to activate TinyMCE in media description field. Default false.
       
  3276 		 */
       
  3277 		'tinymce'       => apply_filters( 'activate_tinymce_for_media_description', false ),
  3242 		'quicktags'     => $quicktags_settings,
  3278 		'quicktags'     => $quicktags_settings,
  3243 	);
  3279 	);
  3244 
  3280 
  3245 	?>
  3281 	?>
  3246 
  3282 
  3277 
  3313 
  3278 	$media_dims = '';
  3314 	$media_dims = '';
  3279 	$meta       = wp_get_attachment_metadata( $attachment_id );
  3315 	$meta       = wp_get_attachment_metadata( $attachment_id );
  3280 
  3316 
  3281 	if ( isset( $meta['width'], $meta['height'] ) ) {
  3317 	if ( isset( $meta['width'], $meta['height'] ) ) {
  3282 		$media_dims .= "<span id='media-dims-$attachment_id'>{$meta['width']}&nbsp;&times;&nbsp;{$meta['height']}</span> ";
  3318 		/* translators: 1: A number of pixels wide, 2: A number of pixels tall. */
       
  3319 		$media_dims .= "<span id='media-dims-$attachment_id'>" . sprintf( __( '%1$s by %2$s pixels' ), $meta['width'], $meta['height'] ) . '</span>';
  3283 	}
  3320 	}
  3284 	/** This filter is documented in wp-admin/includes/media.php */
  3321 	/** This filter is documented in wp-admin/includes/media.php */
  3285 	$media_dims = apply_filters( 'media_meta', $media_dims, $post );
  3322 	$media_dims = apply_filters( 'media_meta', $media_dims, $post );
  3286 
  3323 
  3287 	$att_url = wp_get_attachment_url( $attachment_id );
  3324 	$att_url = wp_get_attachment_url( $attachment_id );
  3329 		<span class="copy-to-clipboard-container">
  3366 		<span class="copy-to-clipboard-container">
  3330 			<button type="button" class="button copy-attachment-url edit-media" data-clipboard-target="#attachment_url"><?php _e( 'Copy URL to clipboard' ); ?></button>
  3367 			<button type="button" class="button copy-attachment-url edit-media" data-clipboard-target="#attachment_url"><?php _e( 'Copy URL to clipboard' ); ?></button>
  3331 			<span class="success hidden" aria-hidden="true"><?php _e( 'Copied!' ); ?></span>
  3368 			<span class="success hidden" aria-hidden="true"><?php _e( 'Copied!' ); ?></span>
  3332 		</span>
  3369 		</span>
  3333 	</div>
  3370 	</div>
       
  3371 	<div class="misc-pub-section misc-pub-download">
       
  3372 		<a href="<?php echo esc_attr( $att_url ); ?>" download><?php _e( 'Download file' ); ?></a>
       
  3373 	</div>
  3334 	<div class="misc-pub-section misc-pub-filename">
  3374 	<div class="misc-pub-section misc-pub-filename">
  3335 		<?php _e( 'File name:' ); ?> <strong><?php echo $filename; ?></strong>
  3375 		<?php _e( 'File name:' ); ?> <strong><?php echo $filename; ?></strong>
  3336 	</div>
  3376 	</div>
  3337 	<div class="misc-pub-section misc-pub-filetype">
  3377 	<div class="misc-pub-section misc-pub-filetype">
  3338 		<?php _e( 'File type:' ); ?>
  3378 		<?php _e( 'File type:' ); ?>
  3409 						echo round( $meta['bitrate'] / 1000 ) . 'kb/s';
  3449 						echo round( $meta['bitrate'] / 1000 ) . 'kb/s';
  3410 						if ( ! empty( $meta['bitrate_mode'] ) ) {
  3450 						if ( ! empty( $meta['bitrate_mode'] ) ) {
  3411 							echo ' ' . strtoupper( esc_html( $meta['bitrate_mode'] ) );
  3451 							echo ' ' . strtoupper( esc_html( $meta['bitrate_mode'] ) );
  3412 						}
  3452 						}
  3413 						break;
  3453 						break;
       
  3454 					case 'length_formatted':
       
  3455 						echo human_readable_duration( $meta['length_formatted'] );
       
  3456 						break;
  3414 					default:
  3457 					default:
  3415 						echo esc_html( $meta[ $key ] );
  3458 						echo esc_html( $meta[ $key ] );
  3416 						break;
  3459 						break;
  3417 				}
  3460 				}
  3418 
  3461 
  3462 		<?php
  3505 		<?php
  3463 	}
  3506 	}
  3464 
  3507 
  3465 	if ( ! empty( $meta['original_image'] ) ) {
  3508 	if ( ! empty( $meta['original_image'] ) ) {
  3466 		?>
  3509 		?>
  3467 		<div class="misc-pub-section misc-pub-original-image">
  3510 		<div class="misc-pub-section misc-pub-original-image word-wrap-break-word">
  3468 			<?php _e( 'Original image:' ); ?>
  3511 			<?php _e( 'Original image:' ); ?>
  3469 			<a href="<?php echo esc_url( wp_get_original_image_url( $attachment_id ) ); ?>">
  3512 			<a href="<?php echo esc_url( wp_get_original_image_url( $attachment_id ) ); ?>">
  3470 				<?php echo esc_html( wp_basename( wp_get_original_image_path( $attachment_id ) ) ); ?>
  3513 				<strong><?php echo esc_html( wp_basename( wp_get_original_image_path( $attachment_id ) ) ); ?></strong>
  3471 			</a>
  3514 			</a>
  3472 		</div>
  3515 		</div>
  3473 		<?php
  3516 		<?php
  3474 	}
  3517 	}
  3475 }
  3518 }
  3487 		if ( ! empty( $data[ $version ]['comments'] ) ) {
  3530 		if ( ! empty( $data[ $version ]['comments'] ) ) {
  3488 			foreach ( $data[ $version ]['comments'] as $key => $list ) {
  3531 			foreach ( $data[ $version ]['comments'] as $key => $list ) {
  3489 				if ( 'length' !== $key && ! empty( $list ) ) {
  3532 				if ( 'length' !== $key && ! empty( $list ) ) {
  3490 					$metadata[ $key ] = wp_kses_post( reset( $list ) );
  3533 					$metadata[ $key ] = wp_kses_post( reset( $list ) );
  3491 					// Fix bug in byte stream analysis.
  3534 					// Fix bug in byte stream analysis.
  3492 					if ( 'terms_of_use' === $key && 0 === strpos( $metadata[ $key ], 'yright notice.' ) ) {
  3535 					if ( 'terms_of_use' === $key && str_starts_with( $metadata[ $key ], 'yright notice.' ) ) {
  3493 						$metadata[ $key ] = 'Cop' . $metadata[ $key ];
  3536 						$metadata[ $key ] = 'Cop' . $metadata[ $key ];
  3494 					}
  3537 					}
  3495 				}
  3538 				}
  3496 			}
  3539 			}
  3497 			break;
  3540 			break;
  3623 	 * In core, usually this selection is what is stored.
  3666 	 * In core, usually this selection is what is stored.
  3624 	 * More complete data can be parsed from the `$data` parameter.
  3667 	 * More complete data can be parsed from the `$data` parameter.
  3625 	 *
  3668 	 *
  3626 	 * @since 4.9.0
  3669 	 * @since 4.9.0
  3627 	 *
  3670 	 *
  3628 	 * @param array  $metadata       Filtered Video metadata.
  3671 	 * @param array       $metadata    Filtered video metadata.
  3629 	 * @param string $file           Path to video file.
  3672 	 * @param string      $file        Path to video file.
  3630 	 * @param string $file_format    File format of video, as analyzed by getID3.
  3673 	 * @param string|null $file_format File format of video, as analyzed by getID3.
  3631 	 * @param array  $data           Raw metadata from getID3.
  3674 	 *                                 Null if unknown.
       
  3675 	 * @param array       $data        Raw metadata from getID3.
  3632 	 */
  3676 	 */
  3633 	return apply_filters( 'wp_read_video_metadata', $metadata, $file, $file_format, $data );
  3677 	return apply_filters( 'wp_read_video_metadata', $metadata, $file, $file_format, $data );
  3634 }
  3678 }
  3635 
  3679 
  3636 /**
  3680 /**
  3695 		}
  3739 		}
  3696 	}
  3740 	}
  3697 
  3741 
  3698 	wp_add_id3_tag_data( $metadata, $data );
  3742 	wp_add_id3_tag_data( $metadata, $data );
  3699 
  3743 
  3700 	return $metadata;
  3744 	$file_format = isset( $metadata['fileformat'] ) ? $metadata['fileformat'] : null;
       
  3745 
       
  3746 	/**
       
  3747 	 * Filters the array of metadata retrieved from an audio file.
       
  3748 	 *
       
  3749 	 * In core, usually this selection is what is stored.
       
  3750 	 * More complete data can be parsed from the `$data` parameter.
       
  3751 	 *
       
  3752 	 * @since 6.1.0
       
  3753 	 *
       
  3754 	 * @param array       $metadata    Filtered audio metadata.
       
  3755 	 * @param string      $file        Path to audio file.
       
  3756 	 * @param string|null $file_format File format of audio, as analyzed by getID3.
       
  3757 	 *                                 Null if unknown.
       
  3758 	 * @param array       $data        Raw metadata from getID3.
       
  3759 	 */
       
  3760 	return apply_filters( 'wp_read_audio_metadata', $metadata, $file, $file_format, $data );
  3701 }
  3761 }
  3702 
  3762 
  3703 /**
  3763 /**
  3704  * Parses creation date from media metadata.
  3764  * Parses creation date from media metadata.
  3705  *
  3765  *
  3810 
  3870 
  3811 		$location = 'upload.php';
  3871 		$location = 'upload.php';
  3812 		$referer  = wp_get_referer();
  3872 		$referer  = wp_get_referer();
  3813 
  3873 
  3814 		if ( $referer ) {
  3874 		if ( $referer ) {
  3815 			if ( false !== strpos( $referer, 'upload.php' ) ) {
  3875 			if ( str_contains( $referer, 'upload.php' ) ) {
  3816 				$location = remove_query_arg( array( 'attached', 'detach' ), $referer );
  3876 				$location = remove_query_arg( array( 'attached', 'detach' ), $referer );
  3817 			}
  3877 			}
  3818 		}
  3878 		}
  3819 
  3879 
  3820 		$key      = 'attach' === $action ? 'attached' : 'detach';
  3880 		$key      = 'attach' === $action ? 'attached' : 'detach';