public
Created

  • Download Gist
gistfile1.diff
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
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 != '' )

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.