WordPress.org

Make WordPress Core

Changeset 27622


Ignore:
Timestamp:
03/19/2014 06:59:31 PM (4 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.

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentyeleven/style.css

    r27570 r27622  
    17071707}
    17081708
     1709/* =Media
     1710-------------------------------------------------------------- */
     1711
     1712audio,
     1713video {
     1714    display: inline-block;
     1715    max-width: 100%;
     1716}
     1717
     1718.attachment .entry-content .mejs-container {
     1719    margin-bottom: 24px;
     1720}
    17091721
    17101722/* =Navigation
  • trunk/src/wp-content/themes/twentythirteen/style.css

    r27607 r27622  
    18381838}
    18391839
     1840.attachment .entry-content .mejs-audio {
     1841    max-width: 400px;
     1842    margin: 0 auto;
     1843}
     1844
     1845.attachment .entry-content .wp-video {
     1846    margin: 0 auto;
     1847}
     1848
     1849.attachment .entry-content .mejs-container {
     1850    margin-bottom: 24px;
     1851}
    18401852
    18411853/**
  • trunk/src/wp-content/themes/twentytwelve/style.css

    r27606 r27622  
    10081008}
    10091009
     1010/* =Single audio/video attachment view
     1011-------------------------------------------------------------- */
     1012
     1013.attachment .entry-content .mejs-audio {
     1014    max-width: 400px;
     1015}
     1016
     1017.attachment .entry-content .mejs-container {
     1018    margin-bottom: 24px;
     1019}
     1020
    10101021
    10111022/* =Single image attachment view
  • 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.