Changeset 41746 for trunk/src/wp-admin/includes/media.php
- Timestamp:
- 10/04/2017 07:31:51 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/media.php
r41581 r41746 3083 3083 } 3084 3084 3085 if ( empty( $metadata['created_timestamp'] ) ) { 3086 $created_timestamp = wp_get_media_creation_timestamp( $data ); 3087 3088 if ( $created_timestamp !== false ) { 3089 $metadata['created_timestamp'] = $created_timestamp; 3090 } 3091 } 3092 3085 3093 wp_add_id3_tag_data( $metadata, $data ); 3086 3094 3087 return $metadata; 3095 $file_format = isset( $metadata['fileformat'] ) ? $metadata['fileformat'] : null; 3096 3097 /** 3098 * Filters the array of metadata retrieved from a video. 3099 * 3100 * In core, usually this selection is what is stored. 3101 * More complete data can be parsed from the `$data` parameter. 3102 * 3103 * @since 4.9.0 3104 * 3105 * @param array $metadata Filtered Video metadata. 3106 * @param string $file Path to video file. 3107 * @param string $file_format File format of video, as analyzed by getID3. 3108 * @param string $data Raw metadata from getID3. 3109 */ 3110 return apply_filters( 'wp_read_video_metadata', $metadata, $file, $file_format, $data ); 3088 3111 } 3089 3112 … … 3134 3157 3135 3158 /** 3159 * Parse creation date from media metadata. 3160 * 3161 * The getID3 library doesn't have a standard method for getting creation dates, 3162 * so the location of this data can vary based on the MIME type. 3163 * 3164 * @since 4.9.0 3165 * 3166 * @link https://github.com/JamesHeinrich/getID3/blob/master/structure.txt 3167 * 3168 * @param array $metadata The metadata returned by getID3::analyze(). 3169 * @return int|bool A UNIX timestamp for the media's creation date if available 3170 * or a boolean FALSE if a timestamp could not be determined. 3171 */ 3172 function wp_get_media_creation_timestamp( $metadata ) { 3173 $creation_date = false; 3174 3175 if ( empty( $metadata['fileformat'] ) ) { 3176 return $creation_date; 3177 } 3178 3179 switch ( $metadata['fileformat'] ) { 3180 case 'asf': 3181 if ( isset( $metadata['asf']['file_properties_object']['creation_date_unix'] ) ) { 3182 $creation_date = (int) $metadata['asf']['file_properties_object']['creation_date_unix']; 3183 } 3184 break; 3185 3186 case 'matroska': 3187 case 'webm': 3188 if ( isset( $metadata['matroska']['comments']['creation_time']['0'] ) ) { 3189 $creation_date = strtotime( $metadata['matroska']['comments']['creation_time']['0'] ); 3190 } 3191 elseif ( isset( $metadata['matroska']['info']['0']['DateUTC_unix'] ) ) { 3192 $creation_date = (int) $metadata['matroska']['info']['0']['DateUTC_unix']; 3193 } 3194 break; 3195 3196 case 'quicktime': 3197 case 'mp4': 3198 if ( isset( $metadata['quicktime']['moov']['subatoms']['0']['creation_time_unix'] ) ) { 3199 $creation_date = (int) $metadata['quicktime']['moov']['subatoms']['0']['creation_time_unix']; 3200 } 3201 break; 3202 } 3203 3204 return $creation_date; 3205 } 3206 3207 /** 3136 3208 * Encapsulate logic for Attach/Detach actions 3137 3209 *
Note: See TracChangeset
for help on using the changeset viewer.