X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/baca9ce86a38dc54c4574890ee2d352fd81f78b2..61343b82c4f0da4c68e4c6373daafff4a81efdd1:/wp-includes/media.php?ds=inline diff --git a/wp-includes/media.php b/wp-includes/media.php index d664e073..6111f363 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -138,16 +138,16 @@ function image_downsize($id, $size = 'medium') { if ( !wp_attachment_is_image($id) ) return false; + // plugins can use this to provide resize services + if ( $out = apply_filters( 'image_downsize', false, $id, $size ) ) + return $out; + $img_url = wp_get_attachment_url($id); $meta = wp_get_attachment_metadata($id); $width = $height = 0; $is_intermediate = false; $img_url_basename = wp_basename($img_url); - // plugins can use this to provide resize services - if ( $out = apply_filters('image_downsize', false, $id, $size) ) - return $out; - // try for a new style intermediate size if ( $intermediate = image_get_intermediate_size($id, $size) ) { $img_url = str_replace($img_url_basename, $intermediate['file'], $img_url); @@ -164,7 +164,7 @@ function image_downsize($id, $size = 'medium') { $is_intermediate = true; } } - if ( !$width && !$height && isset($meta['width'], $meta['height']) ) { + if ( !$width && !$height && isset( $meta['width'], $meta['height'] ) ) { // any other type: use the real image $width = $meta['width']; $height = $meta['height']; @@ -539,6 +539,7 @@ function wp_get_attachment_image_src($attachment_id, $size='thumbnail', $icon = * @param int $attachment_id Image attachment ID. * @param string $size Optional, default is 'thumbnail'. * @param bool $icon Optional, default is false. Whether it is an icon. + * @param mixed $attr Optional, attributes for the image markup. * @return string HTML img element or empty string on failure. */ function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = false, $attr = '') { @@ -644,7 +645,7 @@ function img_caption_shortcode($attr, $content = null) { 'align' => 'alignnone', 'width' => '', 'caption' => '' - ), $attr)); + ), $attr, 'caption')); if ( 1 > (int) $width || empty($caption) ) return $content; @@ -696,7 +697,7 @@ function gallery_shortcode($attr) { extract(shortcode_atts(array( 'order' => 'ASC', 'orderby' => 'menu_order ID', - 'id' => $post->ID, + 'id' => $post ? $post->ID : 0, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', @@ -704,7 +705,7 @@ function gallery_shortcode($attr) { 'size' => 'thumbnail', 'include' => '', 'exclude' => '' - ), $attr)); + ), $attr, 'gallery')); $id = intval($id); if ( 'RAND' == $order ) @@ -769,20 +770,31 @@ function gallery_shortcode($attr) { #{$selector} .gallery-caption { margin-left: 0; } - - "; + /* see gallery_shortcode() in wp-includes/media.php */ + "; $size_class = sanitize_html_class( $size ); $gallery_div = "