WordPress.org

Make WordPress Core

Ticket #23955: 23955.video-width.diff

File 23955.video-width.diff, 1.9 KB (added by obenland, 15 months ago)
  • wp-content/themes/twentythirteen/functions.php

     
    524524add_filter( 'comment_class', 'twentythirteen_comment_class' ); 
    525525 
    526526/** 
    527  * Adjusts content_width value for image post formats, video post formats, and 
    528  * image attachment templates. 
     527 * Adjusts content_width value for video post formats and attachment templates. 
    529528 * 
    530529 * @since Twenty Thirteen 1.0 
     530 * 
     531 * @return void 
    531532 */ 
    532533function twentythirteen_content_width() { 
    533534        if ( has_post_format( 'video' ) || is_attachment() ) { 
     
    538539add_action( 'template_redirect', 'twentythirteen_content_width' ); 
    539540 
    540541/** 
     542 * Adjusts content_width value for video embeds in video post formats and on 
     543 * attachment templates. 
     544 * 
     545 * @since Twenty Thirteen 1.0 
     546 * 
     547 * @param array Embed defaults. 
     548 * @return array Filtered embed defaults. 
     549 */ 
     550function twentythirteen_video_embed_width( $defaults ) { 
     551        if ( has_post_format( 'video' ) || is_attachment() ) { 
     552                $defaults['width']  = 724; 
     553                $defaults['height'] = 1086; // 724 * 1.5. 
     554        } 
     555        return $defaults; 
     556} 
     557add_action( 'embed_defaults', 'twentythirteen_video_embed_width' ); 
     558 
     559/** 
     560 * Adjusts content_width value for video shortcodes in video post formats and 
     561 * on attachment templates. 
     562 * 
     563 * @since Twenty Thirteen 1.0 
     564 * 
     565 * @param array $atts Attribute list. 
     566 * @return array Filtered attribute list. 
     567 */ 
     568function twentythirteen_video_shortcode_width( $atts ) { 
     569        if ( has_post_format( 'video' ) || is_attachment() ) { 
     570 
     571                // Calculate the aspect ratio and apply it to the new width. 
     572                $atts['height'] = 724 * ( $atts['height'] / $atts['width'] ); 
     573                $atts['width']  = 724; 
     574        } 
     575        return $atts; 
     576} 
     577add_action( 'shortcode_atts_video', 'twentythirteen_video_shortcode_width' ); 
     578 
     579/** 
    541580 * Adds entry date to aside posts after the content. 
    542581 * 
    543582 *