diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php
index 9178c3b44..0ef2fb4ce 100644
--- a/wp-admin/includes/file.php
+++ b/wp-admin/includes/file.php
@@ -159,6 +159,9 @@ function wp_handle_upload( &$file, $overrides = false ) {
if ( !$ext )
$ext = ltrim(strrchr($file['name'], '.'), '.');
+
+ if ( !$type )
+ $type = $file['type'];
}
// A writable uploads dir will pass this test. Again, there's no point overriding this one.
diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php
index b6c760e0e..e705e6473 100644
--- a/wp-admin/includes/media.php
+++ b/wp-admin/includes/media.php
@@ -53,10 +53,9 @@ function get_image_send_to_editor($id, $alt, $title, $align, $url='', $rel = fal
$html = get_image_tag($id, $alt, $title, $align, $rel, $size);
$rel = $rel ? ' rel="attachment wp-att-'.attribute_escape($id).'"' : '';
+
if ( $url )
$html = "$html";
- elseif ( $size == 'thumbnail' || $size == 'medium' )
- $html = ''.$html.'';
$html = apply_filters( 'image_send_to_editor', $html, $id, $alt, $title, $align, $url );
@@ -238,14 +237,17 @@ function media_upload_form_handler() {
wp_set_object_terms($attachment_id, array_map('trim', preg_split('/,+/', $attachment[$t])), $t, false);
}
- if ( isset($_POST['insert-media']) )
+ if ( isset($_POST['insert-gallery']) )
return media_send_to_editor('[gallery]');
if ( isset($_POST['send']) ) {
$keys = array_keys($_POST['send']);
$send_id = (int) array_shift($keys);
$attachment = $_POST['attachments'][$send_id];
- $html = apply_filters('media_send_to_editor', get_the_attachment_link($send_id, 0, array(125,125), !empty($attachment['post_content'])), $send_id, $attachment);
+ $html = $attachment['post_title'];
+ if ( !empty($attachment['url']) )
+ $html = "$html";
+ $html = apply_filters('media_send_to_editor', $html, $send_id, $attachment);
return media_send_to_editor($html);
}
@@ -881,7 +883,7 @@ jQuery(function($){
-
+
diff --git a/wp-admin/js/media-upload.js b/wp-admin/js/media-upload.js
index 561aeecd8..b8c615d41 100644
--- a/wp-admin/js/media-upload.js
+++ b/wp-admin/js/media-upload.js
@@ -4,7 +4,7 @@ function send_to_editor(h) {
if ( !win )
win = top;
tinyMCE = win.tinyMCE;
- if ( typeof tinyMCE != 'undefined' && tinyMCE.getInstanceById('content') ) {
+ if ( typeof tinyMCE != 'undefined' && ( ed = tinyMCE.getInstanceById('content') ) && !ed.isHidden() ) {
tinyMCE.selectedInstance.getWin().focus();
tinyMCE.execCommand('mceInsertContent', false, h);
} else
diff --git a/wp-includes/js/swfupload/handlers.js b/wp-includes/js/swfupload/handlers.js
index 189f4d2d6..812567c5a 100644
--- a/wp-includes/js/swfupload/handlers.js
+++ b/wp-includes/js/swfupload/handlers.js
@@ -20,7 +20,7 @@ function fileQueued(fileObj) {
jQuery('#media-items').append('');
// Disable the submit button
- jQuery('#insert-media').attr('disabled', 'disabled');
+ jQuery('#insert-gallery').attr('disabled', 'disabled');
}
function uploadStart(fileObj) { return true; }
@@ -107,7 +107,7 @@ function uploadSuccess(fileObj, serverData) {
function uploadComplete(fileObj) {
// If no more uploads queued, enable the submit button
if ( swfu.getStats().files_queued == 0 )
- jQuery('#insert-media').attr('disabled', '');
+ jQuery('#insert-gallery').attr('disabled', '');
}
diff --git a/wp-includes/media.php b/wp-includes/media.php
index 6739d3b1c..be74d0fe0 100644
--- a/wp-includes/media.php
+++ b/wp-includes/media.php
@@ -290,4 +290,53 @@ function wp_get_attachment_image($attachment_id, $size='thumbnail') {
return $html;
}
+
+add_shortcode('gallery', 'gallery_shortcode');
+
+function gallery_shortcode($attr) {
+ global $post;
+
+ // Allow plugins/themes to override the default gallery template.
+ $output = apply_filters('post_gallery', '', $attr);
+ if ( $output != '' )
+ return $output;
+
+ $attachments = get_children("post_parent=$post->ID&post_type=attachment&post_mime_type=image&orderby=\"menu_order ASC, ID ASC\"");
+
+ if ( empty($attachments) )
+ return '';
+
+ $output = apply_filters('gallery_style', "
+
+ ");
+
+ foreach ( $attachments as $id => $attachment ) {
+ $link = get_the_attachment_link($id, false, array(128, 96), true);
+ $output .= "
+
+ $link
+
";
+ if ( ++$i % 3 == 0 )
+ $output .= '
';
+ }
+
+ $output .= "
+
+
\n";
+
+ return $output;
+}
+
?>
diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php
index a729c2473..247943869 100644
--- a/wp-includes/post-template.php
+++ b/wp-includes/post-template.php
@@ -381,7 +381,7 @@ function wp_get_attachment_link($id = 0, $size = 'thumbnail', $permalink = false
$post_title = attribute_escape($_post->post_title);
- $link_text = wp_get_attachment_image($attachment_id, $size);
+ $link_text = wp_get_attachment_image($id, $size);
if ( !$link_text )
$link_text = $_post->post_title;
diff --git a/wp-includes/post.php b/wp-includes/post.php
index a14c1e56f..e8287e0bd 100644
--- a/wp-includes/post.php
+++ b/wp-includes/post.php
@@ -471,6 +471,7 @@ function get_posts($args) {
$query .= empty( $post_parent ) ? '' : $wpdb->prepare("AND $wpdb->posts.post_parent = %d ", $post_parent);
// expected_slashed ($meta_key, $meta_value) -- Also, this looks really funky, doesn't seem like it works
$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' )";
+ $query .= empty( $post_mime_type ) ? '' : wp_post_mime_type_where($post_mime_type);
$query .= " GROUP BY $wpdb->posts.ID ORDER BY " . $orderby . ' ' . $order;
if ( 0 < $numberposts )
$query .= $wpdb->prepare(" LIMIT %d,%d", $offset, $numberposts);
diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php
index 25f17c2c1..13fda3123 100644
--- a/wp-includes/script-loader.php
+++ b/wp-includes/script-loader.php
@@ -89,8 +89,8 @@ class WP_Scripts {
$this->localize( 'swfupload-handlers', 'swfuploadL10n', array(
'queue_limit_exceeded' => __('You have attempted to queue too many files.'),
'file_exceeds_size_limit' => sprintf(__('This file is too big. Your php.ini upload_max_filesize is %s.'), ini_get('upload_max_filesize')),
- 'zero_byte_file' => __('The file you selected is empty. Please select another file.'),
- 'invalid_filetype' => __('The file you choose is not an allowed file type.'),
+ 'zero_byte_file' => __('This file is empty. Please try another.'),
+ 'invalid_filetype' => __('This file type is not allowed. Please try another.'),
'default_error' => __('An error occurred in the upload. Please try again later.'),
'missing_upload_url' => __('There was a configuration error. Please contact the server administrator.'),
'upload_limit_exceeded' => __('You may only upload 1 file.'),
diff --git a/wp-includes/shortcodes.php b/wp-includes/shortcodes.php
index 0c0553607..7e3bf449e 100644
--- a/wp-includes/shortcodes.php
+++ b/wp-includes/shortcodes.php
@@ -128,64 +128,6 @@ function shortcode_atts($pairs, $atts) {
return $out;
}
-add_shortcode('gallery', 'gallery_shortcode');
-
-function gallery_shortcode($attr) {
- global $post;
-
- // Allow plugins/themes to override the default gallery template.
- $output = apply_filters('post_gallery', '', $attr);
- if ( $output != '' )
- return $output;
-
- $attachments = get_children("post_parent=$post->ID&post_type=attachment&orderby=\"menu_order ASC, ID ASC\"");
-/*
- foreach ( $attachments as $id => $attachment ) {
- $meta = get_post_custom($id);
- if ( $meta ) foreach ( $meta as $k => $v )
- $attachments[$id]->$k = $v;
- if ( isset($attachments[$id]->_wp_attachment_metadata[0]) )
- $attachments[$id]->meta = unserialize($attachments[$id]->_wp_attachment_metadata[0]);
- }
-*/
-
- $output = "
-
-
-";
-
- if ( !empty($attachments) ) foreach ( $attachments as $id => $attachment ) {
- $src = wp_get_attachment_thumb_url($id);
- $href = get_attachment_link($id);
- $output .= "
-
-
-
-";
- if ( ++$i % 3 == 0 )
- $output .= '
';
- }
-
- $output .= "
-
-
-";
-
- return $output;
-}
-
add_filter('the_content', 'do_shortcode');
?>