From ab97039f96417891a4977be9591d14283f331b89 Mon Sep 17 00:00:00 2001
From: Mark Jaquith <markjaquith@git.wordpress.org>
Date: Thu, 10 Dec 2009 06:14:36 +0000
Subject: [PATCH] Post/Page Image was too generic a name. Post/Page Thumbnail
 is more clear, even if you can create very large thumbnail images if you so
 choose.

git-svn-id: https://develop.svn.wordpress.org/trunk@12351 602fd350-edb4-49c9-b593-d223f7449a82
---
 wp-admin/admin-ajax.php                 |  4 +-
 wp-admin/edit-form-advanced.php         |  4 +-
 wp-admin/edit-page-form.php             |  4 +-
 wp-admin/includes/image.php             |  2 +-
 wp-admin/includes/media.php             |  4 +-
 wp-admin/includes/meta-boxes.php        |  6 +-
 wp-admin/includes/post.php              | 14 ++---
 wp-includes/default-filters.php         |  6 +-
 wp-includes/media.php                   | 26 ++++-----
 wp-includes/post-image-template.php     | 76 -------------------------
 wp-includes/post-thumbnail-template.php | 76 +++++++++++++++++++++++++
 wp-includes/script-loader.php           |  2 +-
 wp-includes/theme.php                   |  5 +-
 wp-settings.php                         |  2 +-
 14 files changed, 114 insertions(+), 117 deletions(-)
 delete mode 100644 wp-includes/post-image-template.php
 create mode 100644 wp-includes/post-thumbnail-template.php

diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php
index d0cd5e317b..783e052fd9 100644
--- a/wp-admin/admin-ajax.php
+++ b/wp-admin/admin-ajax.php
@@ -1410,14 +1410,14 @@ case 'set-post-thumbnail':
 
 	if ( $thumbnail_id == '-1' ) {
 		delete_post_meta( $post_id, '_thumbnail_id' );
-		die( _wp_post_image_html() );
+		die( _wp_post_thumbnail_html() );
 	}
 
 	if ( $thumbnail_id && get_post( $thumbnail_id ) ) {
 		$thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'thumbnail' );
 		if ( !empty( $thumbnail_html ) ) {
 			update_post_meta( $post_id, '_thumbnail_id', $thumbnail_id );
-			die( _wp_post_image_html( $thumbnail_id ) );
+			die( _wp_post_thumbnail_html( $thumbnail_id ) );
 		}
 	}
 	die( '0' );
diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php
index 99fb4010dd..085fabca32 100644
--- a/wp-admin/edit-form-advanced.php
+++ b/wp-admin/edit-form-advanced.php
@@ -98,8 +98,8 @@ foreach ( get_object_taxonomies('post') as $tax_name ) {
 }
 
 add_meta_box('categorydiv', __('Categories'), 'post_categories_meta_box', 'post', 'side', 'core');
-if ( current_theme_supports( 'post-images', 'post' ) )
-	add_meta_box('postimagediv', __('Post Image'), 'post_image_meta_box', 'post', 'side', 'low');
+if ( current_theme_supports( 'post-thumbnails', 'post' ) )
+	add_meta_box('postimagediv', __('Post Thumbnail'), 'post_thumbnail_meta_box', 'post', 'side', 'low');
 add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'post', 'normal', 'core');
 add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', 'post', 'normal', 'core');
 add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', 'post', 'normal', 'core');
diff --git a/wp-admin/edit-page-form.php b/wp-admin/edit-page-form.php
index 7bea6a7e1f..79420164f5 100644
--- a/wp-admin/edit-page-form.php
+++ b/wp-admin/edit-page-form.php
@@ -80,8 +80,8 @@ add_meta_box('pageparentdiv', __('Attributes'), 'page_attributes_meta_box', 'pag
 add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', 'page', 'normal', 'core');
 add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', 'page', 'normal', 'core');
 add_meta_box('slugdiv', __('Page Slug'), 'post_slug_meta_box', 'page', 'normal', 'core');
-if ( current_theme_supports( 'post-images', 'page' ) )
-	add_meta_box('postimagediv', __('Page Image'), 'post_image_meta_box', 'page', 'side', 'low');
+if ( current_theme_supports( 'post-thumbnails', 'page' ) )
+	add_meta_box('postimagediv', __('Page Image'), 'post_thumbnail_meta_box', 'page', 'side', 'low');
 
 $authors = get_editable_user_ids( $current_user->id, true, 'page' ); // TODO: ROLE SYSTEM
 if ( $post->post_author && !in_array($post->post_author, $authors) )
diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php
index 0b5e584569..903bd5fe17 100644
--- a/wp-admin/includes/image.php
+++ b/wp-admin/includes/image.php
@@ -75,7 +75,7 @@ function wp_crop_image( $src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_
 }
 
 /**
- * Generate post image attachment meta data.
+ * Generate post thumbnail attachment meta data.
  *
  * @since 2.1.0
  *
diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php
index 8577f93e41..e6277f174c 100644
--- a/wp-admin/includes/media.php
+++ b/wp-admin/includes/media.php
@@ -1239,8 +1239,8 @@ function get_media_item( $attachment_id, $args = null ) {
 	}
 
 	$thumbnail = '';
-	if ( 'image' == $type && isset($_GET['post_id']) && current_theme_supports( 'post-images', get_post_type($_GET['post_id']) ) && get_post_image_id($_GET['post_id']) != $attachment_id )
-		$thumbnail = "<a class='wp-post-thumbnail' href='#' onclick='WPSetAsThumbnail(\"$attachment_id\");return false;'>" . esc_html__( "Use as post image" ) . "</a>";
+	if ( 'image' == $type && isset($_GET['post_id']) && current_theme_supports( 'post-thumbnails', get_post_type($_GET['post_id']) ) && get_post_thumbnail_id($_GET['post_id']) != $attachment_id )
+		$thumbnail = "<a class='wp-post-thumbnail' href='#' onclick='WPSetAsThumbnail(\"$attachment_id\");return false;'>" . esc_html__( "Use as thumbnail" ) . "</a>";
 
 	if ( ( $send || $thumbnail || $delete ) && !isset($form_fields['buttons']) )
 		$form_fields['buttons'] = array('tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>$send $thumbnail $delete</td></tr>\n");
diff --git a/wp-admin/includes/meta-boxes.php b/wp-admin/includes/meta-boxes.php
index 17fc4fd10b..d5e9cb7e82 100644
--- a/wp-admin/includes/meta-boxes.php
+++ b/wp-admin/includes/meta-boxes.php
@@ -815,12 +815,12 @@ function link_advanced_meta_box($link) {
 }
 
 /**
- * Display post image meta box.
+ * Display post thumbnail meta box.
  *
  * @since 2.9.0
  */
-function post_image_meta_box() {
+function post_thumbnail_meta_box() {
 	global $post;
 	$thumbnail_id = get_post_meta( $post->ID, '_thumbnail_id', true );
-	echo _wp_post_image_html( $thumbnail_id );
+	echo _wp_post_thumbnail_html( $thumbnail_id );
 }
diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php
index 225c64600f..9dba35d94f 100644
--- a/wp-admin/includes/post.php
+++ b/wp-admin/includes/post.php
@@ -1062,32 +1062,32 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
 }
 
 /**
- * Output HTML for the post image meta-box.
+ * Output HTML for the post thumbnail meta-box.
  *
  * @since 2.9.0
  *
  * @param int $thumbnail_id ID of the attachment used for thumbnail
  * @return string html
  */
-function _wp_post_image_html( $thumbnail_id = NULL ) {
+function _wp_post_thumbnail_html( $thumbnail_id = NULL ) {
 	global $content_width, $_wp_additional_image_sizes;
-	$content = '<p class="hide-if-no-js"><a href="#" id="set-post-thumbnail" onclick="jQuery(\'#add_image\').click();return false;">' . esc_html__( 'Set image' ) . '</a></p>';
+	$content = '<p class="hide-if-no-js"><a href="#" id="set-post-thumbnail" onclick="jQuery(\'#add_image\').click();return false;">' . esc_html__( 'Set thumbnail' ) . '</a></p>';
 
 	if ( $thumbnail_id && get_post( $thumbnail_id ) ) {
 		$old_content_width = $content_width;
 		$content_width = 266;
-		if ( !isset( $_wp_additional_image_sizes['post-image'] ) )
+		if ( !isset( $_wp_additional_image_sizes['post-thumbnail'] ) )
 			$thumbnail_html = wp_get_attachment_image( $thumbnail_id, array( $content_width, $content_width ) );
 		else
-			$thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'post-image' );
+			$thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'post-thumbnail' );
 		if ( !empty( $thumbnail_html ) ) {
 			$content = '<a href="#" id="set-post-thumbnail" onclick="jQuery(\'#add_image\').click();return false;">' . $thumbnail_html . '</a>';
-			$content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail();return false;">' . esc_html__( 'Remove image' ) . '</a></p>';
+			$content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail();return false;">' . esc_html__( 'Remove thumbnail' ) . '</a></p>';
 		}
 		$content_width = $old_content_width;
 	}
 
-	return apply_filters( 'admin_post_image_html', $content );
+	return apply_filters( 'admin_post_thumbnail_html', $content );
 }
 
 /**
diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php
index 5f6a32deb2..668f389ded 100644
--- a/wp-includes/default-filters.php
+++ b/wp-includes/default-filters.php
@@ -213,9 +213,9 @@ add_action( 'transition_post_status',     '_transition_post_status',  5, 3 );
 add_action( 'comment_form', 'wp_comment_form_unfiltered_html_nonce'        );
 add_action( 'wp_scheduled_delete',        'wp_scheduled_delete' );
 
-// Post Image CSS class filtering
-add_action( 'begin_fetch_post_image_html', '_wp_post_image_class_filter_add'    );
-add_action( 'end_fetch_post_image_html',   '_wp_post_image_class_filter_remove' );
+// Post Thumbnail CSS class filtering
+add_action( 'begin_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_add'    );
+add_action( 'end_fetch_post_thumbnail_html',   '_wp_post_thumbnail_class_filter_remove' );
 
 // Redirect Old Slugs
 add_action( 'template_redirect',  'wp_old_slug_redirect'       );
diff --git a/wp-includes/media.php b/wp-includes/media.php
index cb96bf7ea7..84533d2ca3 100644
--- a/wp-includes/media.php
+++ b/wp-includes/media.php
@@ -183,10 +183,10 @@ function add_image_size( $name, $width = 0, $height = 0, $crop = FALSE ) {
 }
 
 /**
- * Registers an image size for the post image
+ * Registers an image size for the post thumbnail
  */
-function set_post_image_size( $width = 0, $height = 0, $crop = FALSE ) {
-	add_image_size( 'post-image', $width, $height, $crop );
+function set_post_thumbnail_size( $width = 0, $height = 0, $crop = FALSE ) {
+	add_image_size( 'post-thumbnail', $width, $height, $crop );
 }
 
 /**
@@ -578,38 +578,38 @@ function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = fa
 }
 
 /**
- * Adds a 'wp-post-image' class to post image thumbnails
- * Uses the begin_fetch_post_image_html and end_fetch_post_image_html action hooks to
- * dynamically add/remove itself so as to only filter post image thumbnails
+ * Adds a 'wp-post-image' class to post thumbnail thumbnails
+ * Uses the begin_fetch_post_thumbnail_html and end_fetch_post_thumbnail_html action hooks to
+ * dynamically add/remove itself so as to only filter post thumbnail thumbnails
  *
  * @author Mark Jaquith
  * @since 2.9.0
  * @param array $attr Attributes including src, class, alt, title
  * @return array
  */
-function _wp_post_image_class_filter( $attr ) {
+function _wp_post_thumbnail_class_filter( $attr ) {
 	$attr['class'] .= ' wp-post-image';
 	return $attr;
 }
 
 /**
- * Adds _wp_post_image_class_filter to the wp_get_attachment_image_attributes filter
+ * Adds _wp_post_thumbnail_class_filter to the wp_get_attachment_image_attributes filter
  *
  * @author Mark Jaquith
  * @since 2.9.0
  */
-function _wp_post_image_class_filter_add( $attr ) {
-	add_filter( 'wp_get_attachment_image_attributes', '_wp_post_image_class_filter' );
+function _wp_post_thumbnail_class_filter_add( $attr ) {
+	add_filter( 'wp_get_attachment_image_attributes', '_wp_post_thumbnail_class_filter' );
 }
 
 /**
- * Removes _wp_post_image_class_filter from the wp_get_attachment_image_attributes filter
+ * Removes _wp_post_thumbnail_class_filter from the wp_get_attachment_image_attributes filter
  *
  * @author Mark Jaquith
  * @since 2.9.0
  */
-function _wp_post_image_class_filter_remove( $attr ) {
-	remove_filter( 'wp_get_attachment_image_attributes', '_wp_post_image_class_filter' );
+function _wp_post_thumbnail_class_filter_remove( $attr ) {
+	remove_filter( 'wp_get_attachment_image_attributes', '_wp_post_thumbnail_class_filter' );
 }
 
 add_shortcode('wp_caption', 'img_caption_shortcode');
diff --git a/wp-includes/post-image-template.php b/wp-includes/post-image-template.php
deleted file mode 100644
index 1a6b30e7ae..0000000000
--- a/wp-includes/post-image-template.php
+++ /dev/null
@@ -1,76 +0,0 @@
-<?php
-/**
- * WordPress Post Image Template Functions.
- *
- * Support for post images
- * Themes function.php must call add_theme_support( 'post-images' ) to use these.
- *
- * @package WordPress
- * @subpackage Template
- */
-
-/**
- * Check if post has an image attached.
- * 
- * @since 2.9.0
- *
- * @param int $post_id Optional. Post ID.
- * @return bool Whether post has an image attached (true) or not (false).
- */
-function has_post_image( $post_id = NULL ) {
-	global $id;
-	$post_id = ( NULL === $post_id ) ? $id : $post_id;
-	return !! get_post_image_id( $post_id );
-}
-
-/**
- * Retrieve Post Image ID.
- * 
- * @since 2.9.0
- *
- * @param int $post_id Optional. Post ID.
- * @return int
- */
-function get_post_image_id( $post_id = NULL ) {
-	global $id;
-	$post_id = ( NULL === $post_id ) ? $id : $post_id;
-	return get_post_meta( $post_id, '_thumbnail_id', true );
-}
-
-/**
- * Display Post Image.
- * 
- * @since 2.9.0
- *
- * @param int $size Optional. Image size.  Defaults to 'post-image', which theme sets using set_post_image_size( $width, $height, $crop_flag );.
- * @param string|array $attr Optional. Query string or array of attributes.
- */
-function the_post_image( $size = 'post-image', $attr = '' ) {
-	echo get_the_post_image( NULL, $size, $attr );
-}
-
-/**
- * Retrieve Post Image.
- * 
- * @since 2.9.0
- *
- * @param int $post_id Optional. Post ID.
- * @param string $size Optional. Image size.  Defaults to 'thumbnail'.
- * @param string|array $attr Optional. Query string or array of attributes.
-  */
-function get_the_post_image( $post_id = NULL, $size = 'post-image', $attr = '' ) {
-	global $id;
-	$post_id = ( NULL === $post_id ) ? $id : $post_id;
-	$post_image_id = get_post_image_id( $post_id );
-	$size = apply_filters( 'post_image_size', $size );
-	if ( $post_image_id ) {
-		do_action( 'begin_fetch_post_image_html', $post_id, $post_image_id, $size ); // for "Just In Time" filtering of all of wp_get_attachment_image()'s filters
-		$html = wp_get_attachment_image( $post_image_id, $size, false, $attr );
-		do_action( 'end_fetch_post_image_html', $post_id, $post_image_id, $size );
-	} else {
-		$html = '';
-	}
-	return apply_filters( 'post_image_html', $html, $post_id, $post_image_id, $size, $attr );
-}
-
-?>
\ No newline at end of file
diff --git a/wp-includes/post-thumbnail-template.php b/wp-includes/post-thumbnail-template.php
new file mode 100644
index 0000000000..baf1bce62a
--- /dev/null
+++ b/wp-includes/post-thumbnail-template.php
@@ -0,0 +1,76 @@
+<?php
+/**
+ * WordPress Post Thumbnail Template Functions.
+ *
+ * Support for post thumbnails
+ * Themes function.php must call add_theme_support( 'post-thumbnails' ) to use these.
+ *
+ * @package WordPress
+ * @subpackage Template
+ */
+
+/**
+ * Check if post has an image attached.
+ * 
+ * @since 2.9.0
+ *
+ * @param int $post_id Optional. Post ID.
+ * @return bool Whether post has an image attached (true) or not (false).
+ */
+function has_post_thumbnail( $post_id = NULL ) {
+	global $id;
+	$post_id = ( NULL === $post_id ) ? $id : $popost-thumbnailst_id;
+	return !! get_post_thumbnail_id( $post_id );
+}
+
+/**
+ * Retrieve Post Thumbnail ID.
+ * 
+ * @since 2.9.0
+ *
+ * @param int $post_id Optional. Post ID.
+ * @return int
+ */
+function get_post_thumbnail_id( $post_id = NULL ) {
+	global $id;
+	$post_id = ( NULL === $post_id ) ? $id : $post_id;
+	return get_post_meta( $post_id, '_thumbnail_id', true );
+}
+
+/**
+ * Display Post Thumbnail.
+ * 
+ * @since 2.9.0
+ *
+ * @param int $size Optional. Image size.  Defaults to 'post-thumbnail', which theme sets using set_post_thumbnail_size( $width, $height, $crop_flag );.
+ * @param string|array $attr Optional. Query string or array of attributes.
+ */
+function the_post_thumbnail( $size = 'post-thumbnail', $attr = '' ) {
+	echo get_the_post_thumbnail( NULL, $size, $attr );
+}
+
+/**
+ * Retrieve Post Thumbnail.
+ * 
+ * @since 2.9.0
+ *
+ * @param int $post_id Optional. Post ID.
+ * @param string $size Optional. Image size.  Defaults to 'thumbnail'.
+ * @param string|array $attr Optional. Query string or array of attributes.
+  */
+function get_the_post_thumbnail( $post_id = NULL, $size = 'post-thumbnail', $attr = '' ) {
+	global $id;
+	$post_id = ( NULL === $post_id ) ? $id : $post_id;
+	$post_thumbnail_id = get_post_thumbnail_id( $post_id );
+	$size = apply_filters( 'post_thumbnail_size', $size );
+	if ( $post_thumbnail_id ) {
+		do_action( 'begin_fetch_post_thumbnail_html', $post_id, $post_thumbnail_id, $size ); // for "Just In Time" filtering of all of wp_get_attachment_image()'s filters
+		$html = wp_get_attachment_image( $post_thumbnail_id, $size, false, $attr );
+		do_action( 'end_fetch_post_thumbnail_html', $post_id, $post_thumbnail_id, $size );
+	} else {
+		$html = '';
+	}
+	return apply_filters( 'post_thumbnail_html', $html, $post_id, $post_thumbnail_id, $size, $attr );
+}
+
+?>
\ No newline at end of file
diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php
index dcbd462d70..580913db12 100644
--- a/wp-includes/script-loader.php
+++ b/wp-includes/script-loader.php
@@ -385,7 +385,7 @@ function wp_default_scripts( &$scripts ) {
 		$scripts->add( 'set-post-thumbnail', "/wp-admin/js/set-post-thumbnail$suffix.js", array( 'jquery' ), '20091021' );
 		$scripts->add_data( 'set-post-thumbnail', 'group', 1 );
 		$scripts->localize( 'set-post-thumbnail', 'setPostThumbnailL10n', array(
-			'setThumbnail' => __( 'Use as post image' ),
+			'setThumbnail' => __( 'Use as thumbnail' ),
 			'saving' => __( 'Saving...' ),
 			'error' => __( 'Could not set that as the thumbnail image. Try a different attachment.' )
 		) );
diff --git a/wp-includes/theme.php b/wp-includes/theme.php
index 463047bcc0..a2639103aa 100644
--- a/wp-includes/theme.php
+++ b/wp-includes/theme.php
@@ -1321,9 +1321,6 @@ function add_custom_image_header($header_callback, $admin_header_callback) {
 function add_theme_support( $feature ) {
 	global $_wp_theme_features;
 
-	if ( 'post-thumbnails' == $feature ) // This was changed during 2.9 beta. I'll be nice and not break things.
-		$feature = 'post-images';
-
 	if ( func_num_args() == 1 )
 		$_wp_theme_features[$feature] = true;
 	else
@@ -1353,7 +1350,7 @@ function current_theme_supports( $feature ) {
 
 	// @todo Allow pluggable arg checking
 	switch ( $feature ) {
-		case 'post-images':
+		case 'post-thumbnails':
 			// post-thumbnails can be registered for only certain content/post types by passing
 			// an array of types to add_theme_support().  If no array was passed, then
 			// any type is accepted
diff --git a/wp-settings.php b/wp-settings.php
index 4fea749f85..01557408a6 100644
--- a/wp-settings.php
+++ b/wp-settings.php
@@ -692,7 +692,7 @@ if ( file_exists(TEMPLATEPATH . '/functions.php') )
 	include(TEMPLATEPATH . '/functions.php');
 
 // Load in support for template functions which the theme supports
-require_if_theme_supports( 'post-images', ABSPATH . WPINC . '/post-image-template.php' );
+require_if_theme_supports( 'post-thumbnails', ABSPATH . WPINC . '/post-thumbnail-template.php' );
 
 /**
  * Runs just before PHP shuts down execution.