Skip to content

@stas /gist:1854115
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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
Something went wrong with that request. Please try again.