Make WordPress Core

Ticket #18311: 18311.php.diff

File 18311.php.diff, 792 bytes (added by nacin, 12 years ago)
  • wp-includes/media.php

     
    724724 * @return string
    725725 */
    726726function img_caption_shortcode($attr, $content = null) {
     727        // New-style shortcode with the caption inside the shortcode with the link and image tags.
     728        if ( ! isset( $attr['caption'] ) ) {
     729                preg_match( '#(<a\s.*?<img\s.*?</a>)(.*)#is', $content, $matches ) || preg_match( '#(<img\s.*?>)(.*)#is', $content, $matches );
     730                if ( $matches ) {
     731                        $content = $matches[1];
     732                        $attr['caption'] = trim( $matches[2] );
     733                }
     734        }
    727735
    728736        // Allow plugins/themes to override the default caption template.
    729737        $output = apply_filters('img_caption_shortcode', '', $attr, $content);