Changeset 27127
- Timestamp:
- 02/07/2014 10:40:32 PM (11 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/media.php
r27036 r27127 2637 2637 elseif ( $attachment_id && 0 === strpos( $post->post_mime_type, 'audio/' ) ): 2638 2638 2639 maybe_regenerate_attachment_metadata( $post ); 2640 2639 2641 echo wp_audio_shortcode( array( 'src' => $att_url ) ); 2640 2642 2641 2643 elseif ( $attachment_id && 0 === strpos( $post->post_mime_type, 'video/' ) ): 2644 2645 maybe_regenerate_attachment_metadata( $post ); 2642 2646 2643 2647 $meta = wp_get_attachment_metadata( $attachment_id ); -
trunk/src/wp-includes/media.php
r27097 r27127 2195 2195 return empty( $gallery['src'] ) ? array() : $gallery['src']; 2196 2196 } 2197 2198 /** 2199 * If an attachment is missing its metadata, try to regenerate it 2200 * 2201 * @param post $attachment Post object. 2202 */ 2203 function maybe_regenerate_attachment_metadata( $attachment ) { 2204 if ( empty( $attachment ) || ( empty( $attachment->ID ) || ! $attachment_id = (int) $attachment->ID ) ) { 2205 return; 2206 } 2207 2208 $file = get_attached_file( $attachment_id ); 2209 $meta = wp_get_attachment_metadata( $attachment_id ); 2210 if ( empty( $meta ) && file_exists( $file ) ) { 2211 $_meta = get_post_meta( $attachment_id ); 2212 $regeneration_lock = 'wp_regenerating_' . $attachment_id; 2213 if ( ! array_key_exists( '_wp_attachment_metadata', $_meta ) && ! get_transient( $regeneration_lock ) ) { 2214 set_transient( $regeneration_lock, $file ); 2215 wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) ); 2216 delete_transient( $regeneration_lock ); 2217 } 2218 } 2219 }
Note: See TracChangeset
for help on using the changeset viewer.