This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git wp-includes/media.php wp-includes/media.php | |
index e3b9008..757999d 100644 | |
--- wp-includes/media.php | |
+++ wp-includes/media.php | |
@@ -725,6 +725,17 @@ add_shortcode('caption', 'img_caption_shortcode'); | |
*/ | |
function img_caption_shortcode($attr, $content = null) { | |
+ // Backwards compatibility for < v3.4.0 shortcode | |
+ if ( !isset( $attr['caption'] ) ) { | |
+ // Searches and returns as caption all text except image tag (with link or not) | |
+ // The image tag (with link or not) is left inside $content | |
+ $count = preg_match( '~((?i:<a.+<img.+</a|<img.+)>)(.*)~i', $content, $matches ); | |
+ if ( $count > 0 ) { | |
+ $content = $matches[1]; | |
+ $attr['caption'] = $matches[2]; | |
+ } | |
+ } | |
+ | |
// Allow plugins/themes to override the default caption template. | |
$output = apply_filters('img_caption_shortcode', '', $attr, $content); | |
if ( $output != '' ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment