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.



git-svn-id: https://develop.svn.wordpress.org/trunk@27622 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2014-03-19 18:59:31 +00:00
parent 1d98cab1ef
commit 33a76e2d06
4 changed files with 53 additions and 5 deletions

View File

@ -1706,6 +1706,18 @@ section.recent-posts .other-recent-posts li:after {
text-transform: uppercase;
}
/* =Media
-------------------------------------------------------------- */
audio,
video {
display: inline-block;
max-width: 100%;
}
.attachment .entry-content .mejs-container {
margin-bottom: 24px;
}
/* =Navigation
-------------------------------------------------------------- */

View File

@ -1837,6 +1837,18 @@ footer.entry-meta {
display: none;
}
.attachment .entry-content .mejs-audio {
max-width: 400px;
margin: 0 auto;
}
.attachment .entry-content .wp-video {
margin: 0 auto;
}
.attachment .entry-content .mejs-container {
margin-bottom: 24px;
}
/**
* 5.7 Post/Paging Navigation

View File

@ -1007,6 +1007,17 @@ footer.entry-meta {
margin-top: 1.571428571rem;
}
/* =Single audio/video attachment view
-------------------------------------------------------------- */
.attachment .entry-content .mejs-audio {
max-width: 400px;
}
.attachment .entry-content .mejs-container {
margin-bottom: 24px;
}
/* =Single image attachment view
-------------------------------------------------------------- */

View File

@ -347,7 +347,7 @@ function get_post_class( $class = '', $post_id = null ) {
if ( post_password_required( $post->ID ) ) {
$classes[] = 'post-password-required';
// Post thumbnails
} elseif ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $post->ID ) ) {
} elseif ( ! is_attachment( $post ) && current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $post->ID ) ) {
$classes[] = 'has-post-thumbnail';
}
@ -1241,10 +1241,23 @@ function prepend_attachment($content) {
if ( empty($post->post_type) || $post->post_type != 'attachment' )
return $content;
$p = '<p class="attachment">';
// show the medium sized image representation of the attachment if available, and link to the raw file
$p .= wp_get_attachment_link(0, 'medium', false);
$p .= '</p>';
if ( wp_attachment_is_image() ):
$p = '<p class="attachment">';
// show the medium sized image representation of the attachment if available, and link to the raw file
$p .= wp_get_attachment_link(0, 'medium', false);
$p .= '</p>';
elseif ( 0 === strpos( $post->post_mime_type, 'video' ) ):
$meta = wp_get_attachment_metadata( get_the_ID() );
$atts = array( 'src' => wp_get_attachment_url() );
if ( ! empty( $meta['width'] ) && ! empty( $meta['height'] ) ) {
$atts['width'] = (int) $meta['width'];
$atts['height'] = (int) $meta['height'];
}
$p = wp_video_shortcode( $atts );
elseif ( 0 === strpos( $post->post_mime_type, 'audio' ) ):
$p = wp_audio_shortcode( array( 'src' => wp_get_attachment_url() ) );
endif;
$p = apply_filters('prepend_attachment', $p);
return "$p\n$content";