Make WordPress Core


Ignore:
Timestamp:
07/02/2008 06:41:11 PM (17 years ago)
Author:
ryan
Message:

Image captions from azaozz. see #6812

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/media.php

    r8029 r8239  
    349349   
    350350    return $html;
     351}
     352
     353add_shortcode('wp_caption', 'wp_caption_shortcode');
     354
     355function wp_caption_shortcode($attr, $content = null) {
     356   
     357    // Allow plugins/themes to override the default caption template.
     358    $output = apply_filters('wp_caption_shortcode', '', $attr, $content);
     359    if ( $output != '' )
     360        return $output;
     361
     362    extract(shortcode_atts(array(
     363        'id'    => '',
     364        'align' => 'alignnone',
     365        'width' => '',
     366        'caption' => ''
     367    ), $attr));
     368   
     369    if ( 1 > (int) $width || empty($caption) )
     370        return $content;
     371   
     372    if ( $id ) $id = 'id="' . $id . '" ';
     373   
     374    return '<dl ' . $id . 'class="wp_caption ' . $align . '" style="width: ' . (10 + (int) $width) . 'px">'
     375    . '<dt class="wp_caption_dt">' . $content . '</dt><dd class="wp_caption_dd">' . $caption . '</dd></dl>';
    351376}
    352377
Note: See TracChangeset for help on using the changeset viewer.