mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Image captions from azaozz. see #6812
git-svn-id: https://develop.svn.wordpress.org/trunk@8239 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -62,6 +62,25 @@ function get_image_send_to_editor($id, $alt, $title, $align, $url='', $rel = fal
|
||||
return $html;
|
||||
}
|
||||
|
||||
function image_add_caption( $html, $id, $alt, $title, $align, $url, $size ) {
|
||||
|
||||
if ( empty($alt) ) return $html;
|
||||
$id = ( 0 < (int) $id ) ? 'attachment_' . $id : '';
|
||||
|
||||
preg_match( '/width="([0-9]+)/', $html, $matches );
|
||||
if ( ! isset($matches[1]) ) return $html;
|
||||
$width = $matches[1];
|
||||
|
||||
$html = preg_replace( '/align[^\s\'"]+\s?/', '', $html );
|
||||
if ( empty($align) ) $align = 'none';
|
||||
|
||||
$shcode = '[wp_caption id="' . $id . '" align="align' . $align
|
||||
. '" width="' . $width . '" caption="' . $alt . '"]' . $html . '[/wp_caption]';
|
||||
|
||||
return apply_filters( 'image_add_caption_shortcode', $shcode, $html );
|
||||
}
|
||||
add_filter( 'image_send_to_editor', 'image_add_caption', 20, 7 );
|
||||
|
||||
function media_send_to_editor($html) {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
|
||||
Reference in New Issue
Block a user