WordPress.org

Make WordPress Core

Changeset 7172


Ignore:
Timestamp:
03/06/08 19:48:54 (7 years ago)
Author:
ryan
Message:

Fix insert, gallery, sizing, type queries, errors, thumbs, type fallback. Props andy. see #5911

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/file.php

    r7130 r7172  
    160160        if ( !$ext ) 
    161161            $ext = ltrim(strrchr($file['name'], '.'), '.'); 
     162 
     163        if ( !$type ) 
     164            $type = $file['type']; 
    162165    } 
    163166 
  • trunk/wp-admin/includes/media.php

    r7170 r7172  
    5454 
    5555    $rel = $rel ? ' rel="attachment wp-att-'.attribute_escape($id).'"' : ''; 
     56 
    5657    if ( $url ) 
    5758        $html = "<a href='".attribute_escape($url)."'$rel>$html</a>"; 
    58     elseif ( $size == 'thumbnail' || $size == 'medium' ) 
    59         $html = '<a href="'.get_attachment_link($id).'"'.$rel.'>'.$html.'</a>'; 
    6059 
    6160    $html = apply_filters( 'image_send_to_editor', $html, $id, $alt, $title, $align, $url ); 
     
    239238    } 
    240239 
    241     if ( isset($_POST['insert-media']) ) 
     240    if ( isset($_POST['insert-gallery']) ) 
    242241        return media_send_to_editor('[gallery]'); 
    243242 
     
    246245        $send_id = (int) array_shift($keys); 
    247246        $attachment = $_POST['attachments'][$send_id]; 
    248         $html = apply_filters('media_send_to_editor', get_the_attachment_link($send_id, 0, array(125,125), !empty($attachment['post_content'])), $send_id, $attachment); 
     247        $html = $attachment['post_title']; 
     248        if ( !empty($attachment['url']) ) 
     249            $html = "<a href='{$attachment['url']}'>$html</a>"; 
     250        $html = apply_filters('media_send_to_editor', $html, $send_id, $attachment); 
    249251        return media_send_to_editor($html); 
    250252    } 
     
    882884</div> 
    883885<p class="submit"> 
    884     <input type="submit" class="submit insert-gallery" name="insert-media" value="<?php _e('Insert gallery into post'); ?>" /> 
     886    <input type="submit" class="submit insert-gallery" name="insert-gallery" value="<?php _e('Insert gallery into post'); ?>" /> 
    885887</p> 
    886888<input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>" /> 
  • trunk/wp-admin/js/media-upload.js

    r7130 r7172  
    55        win = top; 
    66    tinyMCE = win.tinyMCE; 
    7     if ( typeof tinyMCE != 'undefined' && tinyMCE.getInstanceById('content') ) { 
     7    if ( typeof tinyMCE != 'undefined' && ( ed = tinyMCE.getInstanceById('content') ) && !ed.isHidden() ) { 
    88        tinyMCE.selectedInstance.getWin().focus(); 
    99        tinyMCE.execCommand('mceInsertContent', false, h); 
  • trunk/wp-includes/js/swfupload/handlers.js

    r7160 r7172  
    2121 
    2222    // Disable the submit button 
    23     jQuery('#insert-media').attr('disabled', 'disabled'); 
     23    jQuery('#insert-gallery').attr('disabled', 'disabled'); 
    2424} 
    2525 
     
    108108    // If no more uploads queued, enable the submit button 
    109109    if ( swfu.getStats().files_queued == 0 ) 
    110         jQuery('#insert-media').attr('disabled', ''); 
     110        jQuery('#insert-gallery').attr('disabled', ''); 
    111111} 
    112112 
  • trunk/wp-includes/media.php

    r7150 r7172  
    291291} 
    292292 
     293 
     294add_shortcode('gallery', 'gallery_shortcode'); 
     295 
     296function gallery_shortcode($attr) { 
     297    global $post; 
     298 
     299    // Allow plugins/themes to override the default gallery template. 
     300    $output = apply_filters('post_gallery', '', $attr); 
     301    if ( $output != '' ) 
     302        return $output; 
     303 
     304    $attachments = get_children("post_parent=$post->ID&post_type=attachment&post_mime_type=image&orderby=\"menu_order ASC, ID ASC\""); 
     305 
     306    if ( empty($attachments) ) 
     307        return ''; 
     308 
     309    $output = apply_filters('gallery_style', " 
     310        <style type='text/css'> 
     311            .gallery { 
     312                margin: auto; 
     313            } 
     314            .gallery div { 
     315                float: left; 
     316                margin-top: 10px; 
     317                text-align: center; 
     318                width: 33%;         } 
     319            .gallery img { 
     320                border: 2px solid #cfcfcf; 
     321            } 
     322        </style> 
     323        <div class='gallery'>"); 
     324 
     325    foreach ( $attachments as $id => $attachment ) { 
     326        $link = get_the_attachment_link($id, false, array(128, 96), true); 
     327        $output .= " 
     328            <div> 
     329                $link 
     330            </div>"; 
     331        if ( ++$i % 3 == 0 ) 
     332            $output .= '<br style="clear: both" />'; 
     333    } 
     334 
     335    $output .= " 
     336            <br style='clear: both;' > 
     337        </div>\n"; 
     338 
     339    return $output; 
     340} 
     341 
    293342?> 
  • trunk/wp-includes/post-template.php

    r7149 r7172  
    382382    $post_title = attribute_escape($_post->post_title); 
    383383 
    384     $link_text = wp_get_attachment_image($attachment_id, $size); 
     384    $link_text = wp_get_attachment_image($id, $size); 
    385385    if ( !$link_text ) 
    386386        $link_text = $_post->post_title; 
  • trunk/wp-includes/post.php

    r7161 r7172  
    472472    // expected_slashed ($meta_key, $meta_value) -- Also, this looks really funky, doesn't seem like it works 
    473473    $query .= empty( $meta_key ) | empty($meta_value)  ? '' : " AND ($wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '$meta_key' AND $wpdb->postmeta.meta_value = '$meta_value' )"; 
     474    $query .= empty( $post_mime_type ) ? '' : wp_post_mime_type_where($post_mime_type); 
    474475    $query .= " GROUP BY $wpdb->posts.ID ORDER BY " . $orderby . ' ' . $order; 
    475476    if ( 0 < $numberposts ) 
  • trunk/wp-includes/script-loader.php

    r7165 r7172  
    9090                'queue_limit_exceeded' => __('You have attempted to queue too many files.'), 
    9191                'file_exceeds_size_limit' => sprintf(__('This file is too big. Your php.ini upload_max_filesize is %s.'), ini_get('upload_max_filesize')), 
    92                 'zero_byte_file' => __('The file you selected is empty. Please select another file.'), 
    93                 'invalid_filetype' => __('The file you choose is not an allowed file type.'), 
     92                'zero_byte_file' => __('This file is empty. Please try another.'), 
     93                'invalid_filetype' => __('This file type is not allowed. Please try another.'), 
    9494                'default_error' => __('An error occurred in the upload. Please try again later.'), 
    9595                'missing_upload_url' => __('There was a configuration error. Please contact the server administrator.'), 
  • trunk/wp-includes/shortcodes.php

    r6939 r7172  
    129129} 
    130130 
    131 add_shortcode('gallery', 'gallery_shortcode'); 
    132  
    133 function gallery_shortcode($attr) { 
    134     global $post; 
    135  
    136     // Allow plugins/themes to override the default gallery template. 
    137     $output = apply_filters('post_gallery', '', $attr); 
    138     if ( $output != '' ) 
    139         return $output; 
    140  
    141     $attachments = get_children("post_parent=$post->ID&post_type=attachment&orderby=\"menu_order ASC, ID ASC\""); 
    142 /* 
    143     foreach ( $attachments as $id => $attachment ) { 
    144         $meta = get_post_custom($id); 
    145         if ( $meta ) foreach ( $meta as $k => $v ) 
    146             $attachments[$id]->$k = $v; 
    147         if ( isset($attachments[$id]->_wp_attachment_metadata[0]) ) 
    148             $attachments[$id]->meta = unserialize($attachments[$id]->_wp_attachment_metadata[0]); 
    149     } 
    150 */ 
    151  
    152     $output = " 
    153         <style type='text/css'> 
    154             .gallery { 
    155                 margin: auto; 
    156             } 
    157             .gallery div { 
    158                 float: left; 
    159                 margin-top: 10px; 
    160                 text-align: center; 
    161                 width: 33%;         } 
    162             .gallery img { 
    163                 border: 2px solid #cfcfcf; 
    164             } 
    165         </style> 
    166         <div class='gallery'> 
    167 "; 
    168  
    169     if ( !empty($attachments) ) foreach ( $attachments as $id => $attachment ) { 
    170         $src = wp_get_attachment_thumb_url($id); 
    171         $href = get_attachment_link($id); 
    172         $output .= " 
    173             <div> 
    174                 <a href='$href'><img src='$src' alt='$attachment->post_title' /></a> 
    175             </div> 
    176 "; 
    177         if ( ++$i % 3 == 0 ) 
    178             $output .= '<br style="clear: both" />'; 
    179     } 
    180  
    181     $output .= " 
    182             <br style='clear: both;' > 
    183         </div> 
    184 "; 
    185  
    186     return $output; 
    187 } 
    188  
    189131add_filter('the_content', 'do_shortcode'); 
    190132 
Note: See TracChangeset for help on using the changeset viewer.