X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/449d082fcc4873c1f7d363a0d9f7409be7f6e77d..67ba21ec17b4640df9bbe7701072d10ab2b05b63:/wp-includes/media.php diff --git a/wp-includes/media.php b/wp-includes/media.php index 58feaf3a..7f349638 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -200,10 +200,10 @@ function get_image_tag($id, $alt, $title, $align, $size='medium') { list( $img_src, $width, $height ) = image_downsize($id, $size); $hwstring = image_hwstring($width, $height); - $class = 'align'.attribute_escape($align).' size-'.attribute_escape($size).' wp-image-'.$id; + $class = 'align' . esc_attr($align) .' size-' . esc_attr($size) . ' wp-image-' . $id; $class = apply_filters('get_image_tag_class', $class, $id, $align, $size); - $html = ''.attribute_escape($alt).''; + $html = '' . esc_attr($alt) . ''; $html = apply_filters( 'get_image_tag', $html, $id, $alt, $title, $align, $size ); @@ -231,10 +231,10 @@ function wp_constrain_dimensions( $current_width, $current_height, $max_width=0, $width_ratio = $height_ratio = 1.0; - if ( $max_width > 0 && $current_width > $max_width ) + if ( $max_width > 0 && $current_width > 0 && $current_width > $max_width ) $width_ratio = $max_width / $current_width; - if ( $max_height > 0 && $current_height > $max_height ) + if ( $max_height > 0 && $current_height > 0 && $current_height > $max_height ) $height_ratio = $max_height / $current_height; // the smaller ratio is the one we need to fit it to the constraining box @@ -378,7 +378,7 @@ function image_resize( $file, $max_w, $max_h, $crop=false, $suffix=null, $dest_p else { // all other formats are converted to jpg $destfilename = "{$dir}/{$name}-{$suffix}.jpg"; - if (!imagejpeg( $newimage, $destfilename, apply_filters( 'jpeg_quality', $jpeg_quality ) ) ) + if (!imagejpeg( $newimage, $destfilename, apply_filters( 'jpeg_quality', $jpeg_quality, 'image_resize' ) ) ) return new WP_Error('resize_path_invalid', __( 'Resize path invalid' )); } @@ -503,6 +503,8 @@ function wp_get_attachment_image_src($attachment_id, $size='thumbnail', $icon = if ( $image = image_downsize($attachment_id, $size) ) return $image; + $src = false; + if ( $icon && $src = wp_mime_type_icon($attachment_id) ) { $icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/crystal' ); $src_file = $icon_dir . '/' . basename($src); @@ -514,9 +516,10 @@ function wp_get_attachment_image_src($attachment_id, $size='thumbnail', $icon = } /** - * Retrieve img HTML content for an image to represent an attachment. + * Get an HTML img element representing an image attachment * - * @see wp_get_attachment_image_src() Returns img HTML element based on array. + * @uses apply_filters() Calls 'wp_get_attachment_image_attributes' hook on attributes array + * @uses wp_get_attachment_image_src() Gets attachment file URL and dimensions * @since 2.5.0 * * @param int $attachment_id Image attachment ID. @@ -533,7 +536,20 @@ function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = fa $hwstring = image_hwstring($width, $height); if ( is_array($size) ) $size = join('x', $size); - $html = ''; + $attachment =& get_post($attachment_id); + $attr = array( + 'src' => $src, + 'class' => "attachment-$size", + 'alt' => trim(strip_tags( $attachment->post_excerpt )), + 'title' => trim(strip_tags( $attachment->post_title )), + ); + $attr = apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment ); + $attr = array_map( 'esc_attr', $attr ); + $html = rtrim(" $value ) { + $html .= " $name=" . '"' . $value . '"'; + } + $html .= ' />'; } return $html; @@ -578,7 +594,7 @@ function img_caption_shortcode($attr, $content = null) { if ( $id ) $id = 'id="' . $id . '" '; return '
' - . $content . '

' . $caption . '

'; + . do_shortcode( $content ) . '

' . $caption . '

'; } add_shortcode('gallery', 'gallery_shortcode'); @@ -597,6 +613,9 @@ add_shortcode('gallery', 'gallery_shortcode'); function gallery_shortcode($attr) { global $post; + static $instance = 0; + $instance++; + // Allow plugins/themes to override the default gallery template. $output = apply_filters('post_gallery', '', $attr); if ( $output != '' ) @@ -628,8 +647,8 @@ function gallery_shortcode($attr) { if ( is_feed() ) { $output = "\n"; - foreach ( $attachments as $id => $attachment ) - $output .= wp_get_attachment_link($id, $size, true) . "\n"; + foreach ( $attachments as $att_id => $attachment ) + $output .= wp_get_attachment_link($att_id, $size, true) . "\n"; return $output; } @@ -638,25 +657,27 @@ function gallery_shortcode($attr) { $columns = intval($columns); $itemwidth = $columns > 0 ? floor(100/$columns) : 100; + $selector = "gallery-{$instance}"; + $output = apply_filters('gallery_style', " -