Make WordPress Core

Ticket #26825: 26825-prepare.diff

File 26825-prepare.diff, 927 bytes (added by wonderboymusic, 10 years ago)
  • src/wp-includes/media.php

     
    17831783        else
    17841784                list( $type, $subtype ) = array( $attachment->post_mime_type, '' );
    17851785
     1786        // For audio/video, check for existence of meta_key when $meta is empty
     1787        if ( in_array( $type, array( 'audio', 'video' ) ) && empty( $meta ) ) {
     1788                $_meta = get_post_meta( $attachment->ID );
     1789                if ( ! array_key_exists( '_wp_attachment_metadata', $_meta ) ) {
     1790                        // Regenerate the metadata if the file exists
     1791                        $file = get_attached_file( $attachment->ID );
     1792                        $meta = wp_generate_attachment_metadata( $attachment->ID, $file );
     1793                        if ( file_exists( $file ) ) {
     1794                                wp_update_attachment_metadata( $attachment->ID, $meta );
     1795                        }
     1796                }
     1797        }
     1798
    17861799        $attachment_url = wp_get_attachment_url( $attachment->ID );
    17871800
    17881801        $response = array(