WordPress.org

Make WordPress Core

Changeset 44528


Ignore:
Timestamp:
01/10/2019 01:31:52 AM (22 months ago)
Author:
desrosj
Message:

Media: Store audio creation date in meta.

In [41746], wp_get_media_creation_timestamp() was introduced to read the created timestamp for videos from getID3 in meta whenever possible. This information is useful separately from the dates on the file itself.

This adds the same support audio files by utilizing wp_get_media_creation_timestamp() in wp_read_audio_metadata().

Props blob folio, desrosj.
Fixes #42017.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/media.php

    r43642 r44528  
    33413341
    33423342/**
    3343  * Retrieve metadata from a audio file's ID3 tags
     3343 * Retrieve metadata from an audio file's ID3 tags.
    33443344 *
    33453345 * @since 3.6.0
     
    33833383    if ( ! empty( $data['playtime_string'] ) ) {
    33843384        $metadata['length_formatted'] = $data['playtime_string'];
     3385    }
     3386
     3387    if ( empty( $metadata['created_timestamp'] ) ) {
     3388        $created_timestamp = wp_get_media_creation_timestamp( $data );
     3389
     3390        if ( false !==  $created_timestamp ) {
     3391            $metadata['created_timestamp'] = $created_timestamp;
     3392        }
    33853393    }
    33863394
  • trunk/tests/phpunit/tests/media.php

    r43571 r44528  
    23452345
    23462346    /**
     2347     * Test created timestamp is properly read from an MP4 file.
     2348     *
     2349     * This MP4 video file has an AAC audio track, so it can be used to test
     2350     *`wp_read_audio_metadata()`.
     2351     *
     2352     * @ticket 42017
     2353     */
     2354    function test_wp_read_audio_metadata_adds_creation_date_with_mp4() {
     2355        $video    = DIR_TESTDATA . '/uploads/small-video.mp4';
     2356        $metadata = wp_read_audio_metadata( $video );
     2357
     2358        $this->assertEquals( 1269120551, $metadata['created_timestamp'] );
     2359    }
     2360
     2361    /**
    23472362     * @ticket 35218
    23482363     */
Note: See TracChangeset for help on using the changeset viewer.