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

git-svn-id: https://develop.svn.wordpress.org/trunk@7172 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2008-03-06 19:48:54 +00:00
parent 4365b9da33
commit 7d6440bba2
9 changed files with 66 additions and 69 deletions

View File

@@ -20,7 +20,7 @@ function fileQueued(fileObj) {
jQuery('#media-items').append('<div id="media-item-' + fileObj.id + '" class="media-item child-of-' + post_id + '"><div class="filename original">' + fileObj.name + '</div><div class="progress"><div class="bar"></div></div></div>');
// 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', '');
}

View File

@@ -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', "
<style type='text/css'>
.gallery {
margin: auto;
}
.gallery div {
float: left;
margin-top: 10px;
text-align: center;
width: 33%; }
.gallery img {
border: 2px solid #cfcfcf;
}
</style>
<div class='gallery'>");
foreach ( $attachments as $id => $attachment ) {
$link = get_the_attachment_link($id, false, array(128, 96), true);
$output .= "
<div>
$link
</div>";
if ( ++$i % 3 == 0 )
$output .= '<br style="clear: both" />';
}
$output .= "
<br style='clear: both;' >
</div>\n";
return $output;
}
?>

View File

@@ -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;

View File

@@ -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);

View File

@@ -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.'),

View File

@@ -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 = "
<style type='text/css'>
.gallery {
margin: auto;
}
.gallery div {
float: left;
margin-top: 10px;
text-align: center;
width: 33%; }
.gallery img {
border: 2px solid #cfcfcf;
}
</style>
<div class='gallery'>
";
if ( !empty($attachments) ) foreach ( $attachments as $id => $attachment ) {
$src = wp_get_attachment_thumb_url($id);
$href = get_attachment_link($id);
$output .= "
<div>
<a href='$href'><img src='$src' alt='$attachment->post_title' /></a>
</div>
";
if ( ++$i % 3 == 0 )
$output .= '<br style="clear: both" />';
}
$output .= "
<br style='clear: both;' >
</div>
";
return $output;
}
add_filter('the_content', 'do_shortcode');
?>