Make WordPress Core

Ticket #26642: 26642.10.diff

File 26642.10.diff, 4.9 KB (added by azaozz, 11 years ago)
  • src/wp-includes/class-wp-editor.php

     
    333333                                        'preview_styles' => 'font-family font-size font-weight font-style text-decoration text-transform',
    334334
    335335                                        'wpeditimage_disable_captions' => $no_captions,
     336                                        'wpeditimage_html5_captions' => current_theme_supports( 'html5', 'caption' ),
    336337                                        'plugins' => implode( ',', $plugins ),
    337338                                );
    338339
  • src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js

     
    4747                                return c;
    4848                        }
    4949
    50                         width = parseInt( w, 10 ) + 10;
     50                        width = parseInt( w, 10 );
     51                        if ( ! editor.getParam( 'wpeditimage_html5_captions' ) ) {
     52                                width += 10;
     53                        }
    5154
    5255                        return '<div class="mceTemp"><dl id="'+ id +'" class="wp-caption '+ cls +'" style="width: '+ width +'px">' +
    5356                                '<dt class="wp-caption-dt">'+ img +'</dt><dd class="wp-caption-dd">'+ cap +'</dd></dl></div>';
     
    189192
    190193                        html = createImageAndLink( imageData, 'html' );
    191194
    192                         width = imageData.width + 10;
     195                        width = parseInt( imageData.width );
     196
     197                        if ( ! editor.getParam( 'wpeditimage_html5_captions' ) ) {
     198                                width += 10;
     199                        }
     200
    193201                        className = 'align' + imageData.align;
    194202
    195203                        //TODO: shouldn't add the id attribute if it isn't an attachment
     
    391399        editor.on( 'init', function() {
    392400                var dom = editor.dom;
    393401
     402                if ( editor.getParam( 'wpeditimage_html5_captions' ) ) {
     403                        dom.addClass( editor.getBody(), 'html5-caption' );
     404                }
     405
    394406                // Add caption field to the default image dialog
    395407                editor.on( 'wpLoadImageForm', function( event ) {
    396408                        if ( editor.getParam( 'wpeditimage_disable_captions' ) ) {
     
    475487                                        node = editor.selection.getNode();
    476488
    477489                                        if ( data.width ) {
    478                                                 captionWidth = parseInt( data.width, 10 ) + 10;
    479                                                 captionWidth = ' style="width: '+ captionWidth +'px"';
     490                                                captionWidth = parseInt( data.width, 10 );
     491
     492                                                if ( ! editor.getParam( 'wpeditimage_html5_captions' ) ) {
     493                                                        captionWidth += 10;
     494                                                }
     495
     496                                                captionWidth = ' style="width: ' + captionWidth + 'px"';
    480497                                        }
    481498
    482499                                        html = '<dl class="wp-caption alignnone"' + captionWidth + '>' +
     
    539556                                                captionWidth = data.width || imgNode.clientWidth;
    540557
    541558                                                if ( captionWidth ) {
    542                                                         captionWidth = parseInt( captionWidth, 10 ) + 10;
     559                                                        captionWidth = parseInt( captionWidth, 10 );
     560
     561                                                        if ( ! editor.getParam( 'wpeditimage_html5_captions' ) ) {
     562                                                                captionWidth += 10;
     563                                                        }
     564
    543565                                                        captionWidth = ' style="width: '+ captionWidth +'px"';
    544566                                                }
    545567
     
    618640
    619641                        // Remove toolbar to avoid an orphaned toolbar when dragging an image to a new location
    620642                        removeToolbar();
    621 
    622643                });
    623644
    624645                // Prevent IE11 from making dl.wp-caption resizable
     
    654675                                width = event.width || editor.dom.getAttrib( node, 'width' );
    655676
    656677                                if ( width ) {
    657                                         width = parseInt( width, 10 ) + 10;
     678                                        width = parseInt( width, 10 );
     679
     680                                        if ( ! editor.getParam( 'wpeditimage_html5_captions' ) ) {
     681                                                width += 10;
     682                                        }
     683
    658684                                        editor.dom.setStyle( parent, 'width', width + 'px' );
    659685                                }
    660686                        }
  • src/wp-includes/js/tinymce/skins/wordpress/wp-content.css

     
    4040        margin: 10px 0;
    4141}
    4242
     43.html5-caption .wp-caption {
     44        padding: 4px;
     45}
     46
    4347.mceIEcenter {
    4448        text-align: center;
    4549}
  • src/wp-includes/media.php

     
    765765        if ( ! empty( $atts['id'] ) )
    766766                $atts['id'] = 'id="' . esc_attr( $atts['id'] ) . '" ';
    767767
     768        $class = trim( 'wp-caption ' . $atts['align'] . ' ' . $atts['class'] );
     769
     770        if ( current_theme_supports( 'html5', 'caption' ) ) {
     771                return '<figure ' . $atts['id'] . 'style="width: ' . (int) $atts['width'] . 'px;" class="' . esc_attr( $class ) . '">'
     772                . do_shortcode( $content ) . '<figcaption class="wp-caption-text">' . $atts['caption'] . '</figcaption></figure>';
     773        }
     774
    768775        $caption_width = 10 + $atts['width'];
    769776
    770777        /**
     
    788795        if ( $caption_width )
    789796                $style = 'style="width: ' . (int) $caption_width . 'px" ';
    790797
    791         $class = trim( 'wp-caption ' . $atts['align'] . ' ' . $atts['class'] );
    792 
    793798        return '<div ' . $atts['id'] . $style . 'class="' . esc_attr( $class ) . '">'
    794799        . do_shortcode( $content ) . '<p class="wp-caption-text">' . $atts['caption'] . '</p></div>';
    795800}