Make WordPress Core


Ignore:
Timestamp:
05/02/2012 01:14:52 AM (14 years ago)
Author:
azaozz
Message:

Change the image caption shortcode format to [caption ...]<a><img /></a> caption text + htmlcaption. That way HTML tags in captions are better supported and the shortcode wouldn't break when using the wrong quotes. Props sushkov, nacin, fixes #18311

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/media.php

    r20562 r20679  
    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        if ( preg_match( '#((?:<a [^>]+>\s*)?<img [^>]+>(?:\s*</a>)?)(.*)#is', $content, $matches ) ) {
     730            $content = $matches[1];
     731            $attr['caption'] = trim( $matches[2] );
     732        }
     733    }
    727734
    728735    // Allow plugins/themes to override the default caption template.
Note: See TracChangeset for help on using the changeset viewer.