ID ) ) :
$image_edit_button = '';
if ( wp_image_editor_supports( array( 'mime_type' => $post->post_mime_type ) ) ) {
- $nonce = wp_create_nonce( "image_editor-$post->ID" );
+ $nonce = wp_create_nonce( "image_editor-$post->ID" );
$image_edit_button = "
";
}
- ?>
+
+ $open_style = $not_open_style = '';
+ if ( $open ) {
+ $open_style = ' style="display:none"';
+ } else {
+ $not_open_style = ' style="display:none"';
+ }
+ ?>
class="wp_attachment_image wp-clearfix" id="media-head-">
+
class="wp_attachment_image wp-clearfix" id="media-head-">
; ?>)
-
class="image-editor" id="image-editor-">
-
+
class="image-editor" id="image-editor-">
+
- $att_url ) );
- elseif ( $attachment_id && wp_attachment_is( 'video', $post ) ):
+ elseif ( $attachment_id && wp_attachment_is( 'video', $post ) ) :
wp_maybe_generate_attachment_metadata( $post );
$meta = wp_get_attachment_metadata( $attachment_id );
- $w = ! empty( $meta['width'] ) ? min( $meta['width'], 640 ) : 0;
- $h = ! empty( $meta['height'] ) ? $meta['height'] : 0;
+ $w = ! empty( $meta['width'] ) ? min( $meta['width'], 640 ) : 0;
+ $h = ! empty( $meta['height'] ) ? $meta['height'] : 0;
if ( $h && $w < $meta['width'] ) {
$h = round( ( $meta['height'] * $w ) / $meta['width'] );
}
$attr = array( 'src' => $att_url );
if ( ! empty( $w ) && ! empty( $h ) ) {
- $attr['width'] = $w;
+ $attr['width'] = $w;
$attr['height'] = $h;
}
@@ -2780,7 +2987,7 @@
echo wp_video_shortcode( $attr );
- elseif ( isset( $thumb_url[0] ) ):
+ elseif ( isset( $thumb_url[0] ) ) :
?>
@@ -2790,7 +2997,7 @@
+ endif;
+ ?>
+ post_mime_type, 0, 5 ) ) : ?>
+
+
+
+
+
+ Describe the purpose of the image%3$s. Leave empty if the image is purely decorative.' ),
+ esc_url( 'https://www.w3.org/WAI/tutorials/images/decision-tree' ),
+ 'target="_blank" rel="noopener noreferrer"',
+ sprintf(
+ ' %s',
+ /* translators: accessibility text */
+ __( '(opens in a new tab)' )
+ )
+ );
+ ?>
+
+
+
-
- post_mime_type, 0, 5 ) ) : ?>
-
-
-
-
-
-
'strong,em,link,block,del,ins,img,ul,ol,li,code,close' );
- $editor_args = array(
+ $editor_args = array(
'textarea_name' => 'content',
'textarea_rows' => 5,
'media_buttons' => false,
- 'tinymce' => false,
- 'quicktags' => $quicktags_settings,
+ 'tinymce' => false,
+ 'quicktags' => $quicktags_settings,
);
?>
-
+
post_content, 'attachment_content', $editor_args ); ?>
@@ -2849,18 +3074,19 @@
function attachment_submitbox_metadata() {
$post = get_post();
- $file = get_attached_file( $post->ID );
+ $file = get_attached_file( $post->ID );
$filename = esc_html( wp_basename( $file ) );
$media_dims = '';
- $meta = wp_get_attachment_metadata( $post->ID );
- if ( isset( $meta['width'], $meta['height'] ) )
+ $meta = wp_get_attachment_metadata( $post->ID );
+ if ( isset( $meta['width'], $meta['height'] ) ) {
$media_dims .= "
{$meta['width']} × {$meta['height']} ";
+ }
/** This filter is documented in wp-admin/includes/media.php */
$media_dims = apply_filters( 'media_meta', $media_dims, $post );
$att_url = wp_get_attachment_url( $post->ID );
-?>
+ ?>
@@ -2869,30 +3095,34 @@
- ID ), $matches ) ) {
- echo esc_html( strtoupper( $matches[1] ) );
- list( $mime_type ) = explode( '/', $post->post_mime_type );
- if ( $mime_type !== 'image' && ! empty( $meta['mime_type'] ) ) {
- if ( $meta['mime_type'] !== "$mime_type/" . strtolower( $matches[1] ) ) {
- echo ' (' . $meta['mime_type'] . ')';
+
+ ID ), $matches ) ) {
+ echo esc_html( strtoupper( $matches[1] ) );
+ list( $mime_type ) = explode( '/', $post->post_mime_type );
+ if ( $mime_type !== 'image' && ! empty( $meta['mime_type'] ) ) {
+ if ( $meta['mime_type'] !== "$mime_type/" . strtolower( $matches[1] ) ) {
+ echo ' (' . $meta['mime_type'] . ')';
+ }
+ }
+ } else {
+ echo strtoupper( str_replace( 'image/', '', $post->post_mime_type ) );
}
- }
- } else {
- echo strtoupper( str_replace( 'image/', '', $post->post_mime_type ) );
- }
- ?>
+ ?>
+
+ if ( isset( $meta['filesize'] ) ) {
+ $file_size = $meta['filesize'];
+ } elseif ( file_exists( $file ) ) {
+ $file_size = filesize( $file );
+ }
+
+ if ( ! empty( $file_size ) ) :
+ ?>
@@ -2923,28 +3153,30 @@
if ( empty( $meta[ $key ] ) ) {
continue;
}
- ?>
+ ?>
-
+
+ ?>
+
- __( 'Audio Format:' ),
- 'codec' => __( 'Audio Codec:' )
+ 'codec' => __( 'Audio Codec:' ),
);
/**
@@ -2965,20 +3197,20 @@
if ( empty( $meta['audio'][ $key ] ) ) {
continue;
}
- ?>
+ ?>
-
+
-
+ if ( $media_dims ) :
+ ?>
- $list ) {
+ if ( ! empty( $data[ $version ]['comments'] ) ) {
+ foreach ( $data[ $version ]['comments'] as $key => $list ) {
if ( 'length' !== $key && ! empty( $list ) ) {
- $metadata[$key] = wp_kses_post( reset( $list ) );
+ $metadata[ $key ] = wp_kses_post( reset( $list ) );
// Fix bug in byte stream analysis.
- if ( 'terms_of_use' === $key && 0 === strpos( $metadata[$key], 'yright notice.' ) )
- $metadata[$key] = 'Cop' . $metadata[$key];
+ if ( 'terms_of_use' === $key && 0 === strpos( $metadata[ $key ], 'yright notice.' ) ) {
+ $metadata[ $key ] = 'Cop' . $metadata[ $key ];
+ }
}
}
break;
@@ -3006,13 +3239,13 @@
}
if ( ! empty( $data['id3v2']['APIC'] ) ) {
- $image = reset( $data['id3v2']['APIC']);
+ $image = reset( $data['id3v2']['APIC'] );
if ( ! empty( $image['data'] ) ) {
$metadata['image'] = array(
- 'data' => $image['data'],
- 'mime' => $image['image_mime'],
- 'width' => $image['image_width'],
- 'height' => $image['image_height']
+ 'data' => $image['data'],
+ 'mime' => $image['image_mime'],
+ 'width' => $image['image_width'],
+ 'height' => $image['image_height'],
);
}
} elseif ( ! empty( $data['comments']['picture'] ) ) {
@@ -3020,7 +3253,7 @@
if ( ! empty( $image['data'] ) ) {
$metadata['image'] = array(
'data' => $image['data'],
- 'mime' => $image['image_mime']
+ 'mime' => $image['image_mime'],
);
}
}
@@ -3048,35 +3281,48 @@
if ( ! class_exists( 'getID3', false ) ) {
require( ABSPATH . WPINC . '/ID3/getid3.php' );
}
- $id3 = new getID3();
+ $id3 = new getID3();
$data = $id3->analyze( $file );
- if ( isset( $data['video']['lossless'] ) )
+ if ( isset( $data['video']['lossless'] ) ) {
$metadata['lossless'] = $data['video']['lossless'];
- if ( ! empty( $data['video']['bitrate'] ) )
+ }
+ if ( ! empty( $data['video']['bitrate'] ) ) {
$metadata['bitrate'] = (int) $data['video']['bitrate'];
- if ( ! empty( $data['video']['bitrate_mode'] ) )
+ }
+ if ( ! empty( $data['video']['bitrate_mode'] ) ) {
$metadata['bitrate_mode'] = $data['video']['bitrate_mode'];
- if ( ! empty( $data['filesize'] ) )
+ }
+ if ( ! empty( $data['filesize'] ) ) {
$metadata['filesize'] = (int) $data['filesize'];
- if ( ! empty( $data['mime_type'] ) )
+ }
+ if ( ! empty( $data['mime_type'] ) ) {
$metadata['mime_type'] = $data['mime_type'];
- if ( ! empty( $data['playtime_seconds'] ) )
+ }
+ if ( ! empty( $data['playtime_seconds'] ) ) {
$metadata['length'] = (int) round( $data['playtime_seconds'] );
- if ( ! empty( $data['playtime_string'] ) )
+ }
+ if ( ! empty( $data['playtime_string'] ) ) {
$metadata['length_formatted'] = $data['playtime_string'];
- if ( ! empty( $data['video']['resolution_x'] ) )
+ }
+ if ( ! empty( $data['video']['resolution_x'] ) ) {
$metadata['width'] = (int) $data['video']['resolution_x'];
- if ( ! empty( $data['video']['resolution_y'] ) )
+ }
+ if ( ! empty( $data['video']['resolution_y'] ) ) {
$metadata['height'] = (int) $data['video']['resolution_y'];
- if ( ! empty( $data['fileformat'] ) )
+ }
+ if ( ! empty( $data['fileformat'] ) ) {
$metadata['fileformat'] = $data['fileformat'];
- if ( ! empty( $data['video']['dataformat'] ) )
+ }
+ if ( ! empty( $data['video']['dataformat'] ) ) {
$metadata['dataformat'] = $data['video']['dataformat'];
- if ( ! empty( $data['video']['encoder'] ) )
+ }
+ if ( ! empty( $data['video']['encoder'] ) ) {
$metadata['encoder'] = $data['video']['encoder'];
- if ( ! empty( $data['video']['codec'] ) )
+ }
+ if ( ! empty( $data['video']['codec'] ) ) {
$metadata['codec'] = $data['video']['codec'];
+ }
if ( ! empty( $data['audio'] ) ) {
unset( $data['audio']['streams'] );
@@ -3112,7 +3358,7 @@
}
/**
- * Retrieve metadata from a audio file's ID3 tags
+ * Retrieve metadata from an audio file's ID3 tags.
*
* @since 3.6.0
*
@@ -3132,7 +3378,7 @@
if ( ! class_exists( 'getID3', false ) ) {
require( ABSPATH . WPINC . '/ID3/getid3.php' );
}
- $id3 = new getID3();
+ $id3 = new getID3();
$data = $id3->analyze( $file );
if ( ! empty( $data['audio'] ) ) {
@@ -3140,16 +3386,29 @@
$metadata = $data['audio'];
}
- if ( ! empty( $data['fileformat'] ) )
+ if ( ! empty( $data['fileformat'] ) ) {
$metadata['fileformat'] = $data['fileformat'];
- if ( ! empty( $data['filesize'] ) )
+ }
+ if ( ! empty( $data['filesize'] ) ) {
$metadata['filesize'] = (int) $data['filesize'];
- if ( ! empty( $data['mime_type'] ) )
+ }
+ if ( ! empty( $data['mime_type'] ) ) {
$metadata['mime_type'] = $data['mime_type'];
- if ( ! empty( $data['playtime_seconds'] ) )
+ }
+ if ( ! empty( $data['playtime_seconds'] ) ) {
$metadata['length'] = (int) round( $data['playtime_seconds'] );
- if ( ! empty( $data['playtime_string'] ) )
+ }
+ if ( ! empty( $data['playtime_string'] ) ) {
$metadata['length_formatted'] = $data['playtime_string'];
+ }
+
+ if ( empty( $metadata['created_timestamp'] ) ) {
+ $created_timestamp = wp_get_media_creation_timestamp( $data );
+
+ if ( false !== $created_timestamp ) {
+ $metadata['created_timestamp'] = $created_timestamp;
+ }
+ }
wp_add_id3_tag_data( $metadata, $data );
@@ -3188,8 +3447,7 @@
case 'webm':
if ( isset( $metadata['matroska']['comments']['creation_time']['0'] ) ) {
$creation_date = strtotime( $metadata['matroska']['comments']['creation_time']['0'] );
- }
- elseif ( isset( $metadata['matroska']['info']['0']['DateUTC_unix'] ) ) {
+ } elseif ( isset( $metadata['matroska']['info']['0']['DateUTC_unix'] ) ) {
$creation_date = (int) $metadata['matroska']['info']['0']['DateUTC_unix'];
}
break;
@@ -3258,7 +3516,7 @@
}
}
- $key = 'attach' === $action ? 'attached' : 'detach';
+ $key = 'attach' === $action ? 'attached' : 'detach';
$location = add_query_arg( array( $key => $result ), $location );
wp_redirect( $location );
exit;