Changeset 45583 for trunk/src/wp-admin/includes/media.php
- Timestamp:
- 07/01/2019 12:50:14 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/media.php
r45499 r45583 288 288 289 289 $time = current_time( 'mysql' ); 290 if ( $post = get_post( $post_id ) ) { 290 $post = get_post( $post_id ); 291 if ( $post ) { 291 292 // The post date doesn't usually matter for pages, so don't backdate this upload. 292 293 if ( 'page' !== $post->post_type && substr( $post->post_date, 0, 4 ) > 0 ) { … … 370 371 371 372 // Use image exif/iptc data for title and caption defaults if possible. 372 } elseif ( 0 === strpos( $type, 'image/' ) && $image_meta = wp_read_image_metadata( $file ) ) { 373 if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) { 374 $title = $image_meta['title']; 375 } 376 377 if ( trim( $image_meta['caption'] ) ) { 378 $excerpt = $image_meta['caption']; 373 } elseif ( 0 === strpos( $type, 'image/' ) ) { 374 $image_meta = wp_read_image_metadata( $file ); 375 if ( $image_meta ) { 376 if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) { 377 $title = $image_meta['title']; 378 } 379 380 if ( trim( $image_meta['caption'] ) ) { 381 $excerpt = $image_meta['caption']; 382 } 379 383 } 380 384 } … … 421 425 422 426 $time = current_time( 'mysql' ); 423 if ( $post = get_post( $post_id ) ) { 427 $post = get_post( $post_id ); 428 if ( $post ) { 424 429 if ( substr( $post->post_date, 0, 4 ) > 0 ) { 425 430 $time = $post->post_date; … … 439 444 440 445 // Use image exif/iptc data for title and caption defaults if possible. 441 if ( $image_meta = wp_read_image_metadata( $file ) ) { 446 $image_meta = wp_read_image_metadata( $file ); 447 if ( $image_meta ) { 442 448 if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) { 443 449 $title = $image_meta['title']; … … 693 699 if ( ! empty( $_POST['attachments'] ) ) { 694 700 foreach ( $_POST['attachments'] as $attachment_id => $attachment ) { 695 $post = $_post = get_post( $attachment_id, ARRAY_A ); 701 $post = get_post( $attachment_id, ARRAY_A ); 702 $_post = $post; 696 703 697 704 if ( ! current_user_can( 'edit_post', $attachment_id ) ) { … … 836 843 837 844 $type = 'file'; 838 if ( ( $ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src ) ) && ( $ext_type = wp_ext2type( $ext ) ) 839 && ( 'audio' == $ext_type || 'video' == $ext_type ) ) { 845 $ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src ); 846 if ( $ext ) { 847 $ext_type = wp_ext2type( $ext ); 848 if ( 'audio' == $ext_type || 'video' == $ext_type ) { 840 849 $type = $ext_type; 850 } 841 851 } 842 852 … … 1441 1451 continue; 1442 1452 } 1443 if ( $item = get_media_item( $id, array( 'errors' => isset( $errors[ $id ] ) ? $errors[ $id ] : null ) ) ) { 1453 $item = get_media_item( $id, array( 'errors' => isset( $errors[ $id ] ) ? $errors[ $id ] : null ) ); 1454 if ( $item ) { 1444 1455 $output .= "\n<div id='media-item-$id' class='media-item child-of-$attachment->post_parent preloaded'><div class='progress hidden'><div class='bar'></div></div><div id='media-upload-error-$id' class='hidden'></div><div class='filename hidden'></div>$item\n</div>"; 1445 1456 } … … 1463 1474 global $redir_tab; 1464 1475 1465 if ( ( $attachment_id = intval( $attachment_id ) ) && $thumb_url = wp_get_attachment_image_src( $attachment_id, 'thumbnail', true ) ) { 1466 $thumb_url = $thumb_url[0]; 1467 } else { 1468 $thumb_url = false; 1476 $thumb_url = false; 1477 $attachment_id = intval( $attachment_id ); 1478 1479 if ( $attachment_id ) { 1480 $thumb_url = wp_get_attachment_image_src( $attachment_id, 'thumbnail', true ); 1481 if ( $thumb_url ) { 1482 $thumb_url = $thumb_url[0]; 1483 } 1469 1484 } 1470 1485 … … 2754 2769 $table_class = ''; 2755 2770 } else { 2756 $view = $table_class = 'not-image'; 2771 $view = 'not-image'; 2772 $table_class = $view; 2757 2773 } 2758 2774 … … 2837 2853 $browser_uploader = admin_url( 'media-new.php?browser-uploader' ); 2838 2854 2839 if ( $post = get_post() ) { 2855 $post = get_post(); 2856 if ( $post ) { 2840 2857 $browser_uploader .= '&post_id=' . intval( $post->ID ); 2841 2858 } elseif ( ! empty( $GLOBALS['post_ID'] ) ) { … … 2877 2894 function media_upload_max_image_resize() { 2878 2895 $checked = get_user_setting( 'upload_resize' ) ? ' checked="true"' : ''; 2879 $a = $end = ''; 2896 $a = ''; 2897 $end = ''; 2880 2898 2881 2899 if ( current_user_can( 'manage_options' ) ) { … … 2920 2938 } 2921 2939 2922 $thumb_url = false; 2923 if ( $attachment_id = intval( $post->ID ) ) { 2940 $thumb_url = false; 2941 $attachment_id = intval( $post->ID ); 2942 if ( $attachment_id ) { 2924 2943 $thumb_url = wp_get_attachment_image_src( $attachment_id, array( 900, 450 ), true ); 2925 2944 } … … 2938 2957 } 2939 2958 2940 $open_style = $not_open_style = ''; 2959 $open_style = ''; 2960 $not_open_style = ''; 2941 2961 if ( $open ) { 2942 2962 $open_style = ' style="display:none"'; … … 3512 3532 if ( isset( $result ) ) { 3513 3533 $location = 'upload.php'; 3514 if ( $referer = wp_get_referer() ) { 3534 $referer = wp_get_referer(); 3535 if ( $referer ) { 3515 3536 if ( false !== strpos( $referer, 'upload.php' ) ) { 3516 3537 $location = remove_query_arg( array( 'attached', 'detach' ), $referer );
Note: See TracChangeset
for help on using the changeset viewer.