From 2373c1c73338e064667464acea744fa7f1f82e54 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Tue, 26 May 2009 22:33:02 +0000 Subject: [PATCH] Fix the inserting of caption shortcode when the upload path contains "align" git-svn-id: https://develop.svn.wordpress.org/trunk@11462 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/media.php | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 37de525a66..67dd936895 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -130,15 +130,20 @@ function get_image_send_to_editor($id, $alt, $title, $align, $url='', $rel = fal */ function image_add_caption( $html, $id, $alt, $title, $align, $url, $size ) { - if ( empty($alt) || apply_filters( 'disable_captions', '' ) ) return $html; + if ( empty($alt) || apply_filters( 'disable_captions', '' ) ) + return $html; + $id = ( 0 < (int) $id ) ? 'attachment_' . $id : ''; preg_match( '/width="([0-9]+)/', $html, $matches ); - if ( ! isset($matches[1]) ) return $html; + if ( ! isset($matches[1]) ) + return $html; + $width = $matches[1]; - $html = preg_replace( '/align[^\s\'"]+\s?/', '', $html ); - if ( empty($align) ) $align = 'none'; + $html = preg_replace( '/(class=["\'][^\'"]*)align(none|left|right|center)\s?/', '$1', $html ); + if ( empty($align) ) + $align = 'none'; $alt = ! empty($alt) ? addslashes($alt) : ''; @@ -427,13 +432,35 @@ function media_upload_form_handler() { if ( isset($send_id) ) { $attachment = stripslashes_deep( $_POST['attachments'][$send_id] ); + $html = $attachment['post_title']; if ( !empty($attachment['url']) ) { if ( strpos($attachment['url'], 'attachment_id') || false !== strpos($attachment['url'], get_permalink($_POST['post_id'])) ) $rel = " rel='attachment wp-att-" . esc_attr($send_id)."'"; $html = "$html"; } + + + + $html = apply_filters('media_send_to_editor', $html, $send_id, $attachment); + + + + + + + + + + + + + + + + + return media_send_to_editor($html); }