}
elseif ( $size == 'thumbnail' ) {
// fall back to the old thumbnail
- if ( $thumb_file = wp_get_attachment_thumb_file() && $info = getimagesize($thumb_file) ) {
+ if ( ($thumb_file = wp_get_attachment_thumb_file($id)) && $info = getimagesize($thumb_file) ) {
$img_url = str_replace(basename($img_url), basename($thumb_file), $img_url);
$width = $info[0];
$height = $info[1];
}
-// return an <img src /> tag for the given image attachment, scaling it down if requested
+/**
+ * An <img src /> tag for an image attachment, scaling it down if requested.
+ *
+ * {@internal Missing Long Description}}
+ *
+ * @uses apply_filters() The 'get_image_tag_class' filter is the IMG element
+ * class attribute.
+ * @uses apply_filters() The 'get_image_tag' filter is the full IMG element with
+ * all attributes.
+ *
+ * @param int $id Attachment ID.
+ * @param string $alt Image Description for the alt attribute.
+ * @param string $title Image Description for the title attribute.
+ * @param string $align Part of the class name for aligning the image.
+ * @param string $size Optional. Default is 'medium'.
+ * @return string HTML IMG element for given image attachment
+ */
function get_image_tag($id, $alt, $title, $align, $size='medium') {
list( $img_src, $width, $height ) = image_downsize($id, $size);
$hwstring = image_hwstring($width, $height);
- $html = '<img src="'.attribute_escape($img_src).'" alt="'.attribute_escape($alt).'" title="'.attribute_escape($title).'" '.$hwstring.'class="align'.attribute_escape($align).' size-'.attribute_escape($size).' wp-image-'.$id.'" />';
+ $class = 'align'.attribute_escape($align).' size-'.attribute_escape($size).' wp-image-'.$id;
+ $class = apply_filters('get_image_tag_class', $class, $id, $align, $size);
- $url = '';
- $html = apply_filters( 'image_send_to_editor', $html, $id, $alt, $title, $align, $url, $size );
+ $html = '<img src="'.attribute_escape($img_src).'" alt="'.attribute_escape($alt).'" title="'.attribute_escape($title).'" '.$hwstring.'class="'.$class.'" />';
+
+ $html = apply_filters( 'get_image_tag', $html, $id, $alt, $title, $align, $size );
return $html;
}
}
function image_get_intermediate_size($post_id, $size='thumbnail') {
- if ( !$imagedata = wp_get_attachment_metadata( $post_id ) )
+ if ( !is_array( $imagedata = wp_get_attachment_metadata( $post_id ) ) )
return false;
// get the best one for a specified set of dimensions
return $image;
if ( $icon && $src = wp_mime_type_icon($attachment_id) ) {
- $icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/crystal' );
+ $icon_dir = apply_filters( 'icon_dir', includes_url('images/crystal') );
$src_file = $icon_dir . '/' . basename($src);
@list($width, $height) = getimagesize($src_file);
}
return $html;
}
+add_shortcode('wp_caption', 'img_caption_shortcode');
+add_shortcode('caption', 'img_caption_shortcode');
+
+function img_caption_shortcode($attr, $content = null) {
+
+ // Allow plugins/themes to override the default caption template.
+ $output = apply_filters('img_caption_shortcode', '', $attr, $content);
+ if ( $output != '' )
+ return $output;
+
+ extract(shortcode_atts(array(
+ 'id' => '',
+ 'align' => 'alignnone',
+ 'width' => '',
+ 'caption' => ''
+ ), $attr));
+
+ if ( 1 > (int) $width || empty($caption) )
+ return $content;
+
+ if ( $id ) $id = 'id="' . $id . '" ';
+
+ return '<div ' . $id . 'class="wp-caption ' . $align . '" style="width: ' . (10 + (int) $width) . 'px">'
+ . $content . '<p class="wp-caption-text">' . $caption . '</p></div>';
+}
+
add_shortcode('gallery', 'gallery_shortcode');
function gallery_shortcode($attr) {
}
extract(shortcode_atts(array(
- 'orderby' => 'menu_order ASC, ID ASC',
+ 'order' => 'ASC',
+ 'orderby' => 'menu_order ID',
'id' => $post->ID,
'itemtag' => 'dl',
'icontag' => 'dt',
), $attr));
$id = intval($id);
- $attachments = get_children("post_parent=$id&post_type=attachment&post_mime_type=image&orderby={$orderby}");
+ $attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
if ( empty($attachments) )
return '';
function adjacent_image_link($prev = true) {
global $post;
$post = get_post($post);
- $attachments = array_values(get_children("post_parent=$post->post_parent&post_type=attachment&post_mime_type=image&orderby=menu_order ASC, ID ASC"));
+ $attachments = array_values(get_children( array('post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') ));
foreach ( $attachments as $k => $attachment )
if ( $attachment->ID == $post->ID )