Changeset 7496

Show
Ignore:
Timestamp:
03/24/08 02:57:19 (6 months ago)
Author:
ryan
Message:

Gallery display enhancements from tellyworth. fixes #6368

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-admin/includes/media.php

    r7491 r7496  
    461461    if ( substr($post->post_mime_type, 0, 5) == 'image' ) { 
    462462        $form_fields['post_title']['required'] = true; 
    463         $form_fields['post_excerpt']['label'] = __('Description'); 
     463        $form_fields['post_excerpt']['label'] = __('Caption'); 
    464464        $form_fields['post_excerpt']['helps'][] = __('Alternate text, e.g. "The Mona Lisa"'); 
    465465 
    466         $form_fields['post_content']['label'] = __('Long Description'); 
     466        $form_fields['post_content']['label'] = __('Description'); 
    467467 
    468468        $thumb = wp_get_attachment_thumb_url($post->ID); 
     
    555555        ), 
    556556        'post_excerpt' => array( 
    557             'label'      => __('Description'), 
     557            'label'      => __('Caption'), 
    558558            'value'      => $edit_post->post_excerpt, 
    559559        ), 
    560560        'post_content' => array( 
    561             'label'      => __('Long description'), 
     561            'label'      => __('Description'), 
    562562            'value'      => $edit_post->post_content, 
    563563            'input'      => 'textarea', 
  • trunk/wp-includes/media.php

    r7478 r7496  
    340340    if ( $output != '' ) 
    341341        return $output; 
    342  
    343     $attachments = get_children("post_parent=$post->ID&post_type=attachment&post_mime_type=image&orderby=\"menu_order ASC, ID ASC\""); 
     342         
     343    extract(shortcode_atts(array( 
     344        'orderby'    => 'menu_order ASC, ID ASC', 
     345        'id'         => $post->ID, 
     346        'itemtag'    => 'dl', 
     347        'icontag'    => 'dt', 
     348        'captiontag' => 'dd', 
     349        'columns'    => 3, 
     350        'size'       => 'thumbnail', 
     351    ), $attr)); 
     352 
     353    $id = intval($id); 
     354    $orderby = addslashes($orderby); 
     355    $attachments = get_children("post_parent=$id&post_type=attachment&post_mime_type=image&orderby=\"{$orderby}\""); 
    344356 
    345357    if ( empty($attachments) ) 
     
    349361        $output = "\n"; 
    350362        foreach ( $attachments as $id => $attachment ) 
    351             $output .= wp_get_attachment_link($id, 'thumbnail', true) . "\n"; 
     363            $output .= wp_get_attachment_link($id, $size, true) . "\n"; 
    352364        return $output; 
    353365    } 
    354366 
     367    $listtag = tag_escape($listtag); 
     368    $itemtag = tag_escape($itemtag); 
     369    $captiontag = tag_escape($captiontag); 
     370    $columns = intval($columns); 
     371     
    355372    $output = apply_filters('gallery_style', " 
    356373        <style type='text/css'> 
     
    358375                margin: auto; 
    359376            } 
    360             .gallery div
     377            .gallery-item
    361378                float: left; 
    362379                margin-top: 10px; 
     
    366383                border: 2px solid #cfcfcf; 
    367384            } 
     385            .gallery-caption { 
     386                margin-left: 0; 
     387            } 
    368388        </style> 
    369389        <!-- see gallery_shortcode() in wp-includes/media.php --> 
     
    371391 
    372392    foreach ( $attachments as $id => $attachment ) { 
    373         $link = wp_get_attachment_link($id, 'thumbnail', true); 
     393        $link = wp_get_attachment_link($id, $size, true); 
     394        $output .= "<{$itemtag} class='gallery-item'>"; 
    374395        $output .= " 
    375             <div
     396            <{$icontag} class='gallery-icon'
    376397                $link 
    377             </div>"; 
    378         if ( ++$i % 3 == 0 ) 
     398            </{$icontag}>"; 
     399        if ( $captiontag && trim($attachment->post_excerpt) ) { 
     400            $output .= " 
     401                <{$captiontag} class='gallery-caption'> 
     402                {$attachment->post_excerpt} 
     403                </{$captiontag}>"; 
     404        } 
     405        $output .= "</{$itemtag}>"; 
     406        if ( $columns > 0 && ++$i % $columns == 0 ) 
    379407            $output .= '<br style="clear: both" />'; 
    380408    } 
  • trunk/wp-includes/shortcodes.php

    r7172 r7496  
    119119 
    120120function shortcode_atts($pairs, $atts) { 
     121    $atts = (array)$atts; 
    121122    $out = array(); 
    122123    foreach($pairs as $name => $default) {