Make WordPress Core


Ignore:
Timestamp:
03/19/2014 06:59:31 PM (12 years ago)
Author:
wonderboymusic
Message:

On attachment pages for audio and video, display players. Currently, only a link is displayed. Add minimal CSS rules for compatibility with 2011, 2012, and 2013 themes.

In prepend_attachment, add logic to support attachment types that are not image.

In get_post_class(), don't add the has-post-thumbnail class for attachment pages.

Fixes #27243.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post-template.php

    r27473 r27622  
    348348        $classes[] = 'post-password-required';
    349349    // Post thumbnails
    350     } elseif ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $post->ID ) ) {
     350    } elseif ( ! is_attachment( $post ) && current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $post->ID ) ) {
    351351        $classes[] = 'has-post-thumbnail';
    352352    }
     
    12421242        return $content;
    12431243
    1244     $p = '<p class="attachment">';
    1245     // show the medium sized image representation of the attachment if available, and link to the raw file
    1246     $p .= wp_get_attachment_link(0, 'medium', false);
    1247     $p .= '</p>';
     1244    if ( wp_attachment_is_image() ):
     1245        $p = '<p class="attachment">';
     1246        // show the medium sized image representation of the attachment if available, and link to the raw file
     1247        $p .= wp_get_attachment_link(0, 'medium', false);
     1248        $p .= '</p>';
     1249    elseif ( 0 === strpos( $post->post_mime_type, 'video' ) ):
     1250        $meta = wp_get_attachment_metadata( get_the_ID() );
     1251        $atts = array( 'src' => wp_get_attachment_url() );
     1252        if ( ! empty( $meta['width'] ) && ! empty( $meta['height'] ) ) {
     1253            $atts['width'] = (int) $meta['width'];
     1254            $atts['height'] = (int) $meta['height'];
     1255        }
     1256        $p = wp_video_shortcode( $atts );
     1257    elseif ( 0 === strpos( $post->post_mime_type, 'audio' ) ):
     1258        $p = wp_audio_shortcode( array( 'src' => wp_get_attachment_url() ) );
     1259    endif;
     1260
    12481261    $p = apply_filters('prepend_attachment', $p);
    12491262
Note: See TracChangeset for help on using the changeset viewer.