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: http://svn.automattic.com/wordpress/trunk@12351 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -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' );
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
?>
|
||||
76
wp-includes/post-thumbnail-template.php
Normal file
76
wp-includes/post-thumbnail-template.php
Normal file
@@ -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 );
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -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.' )
|
||||
) );
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user