Make WordPress Core

Opened 15 years ago

Closed 15 years ago

#10928 closed task (blessed) (fixed)

Canonical Post Thumbnails

Reported by: markjaquith's profile markjaquith Owned by: markjaquith's profile markjaquith
Milestone: 2.9 Priority: high
Severity: normal Version:
Component: Post Thumbnails Keywords:
Focuses: Cc:

Description

Many themes and plugins use the concept of a post thumbnail — a representative image for the post. Generally, these are made by laboriously inserting a Custom Field with a full image URL.

WordPress would benefit from having an authoritative way of defining a post thumbnail that uses a GUI instead of custom fields, and specifies an image attachment ID instead of a URL so that themes may get that image in any size they want.

Attachments (9)

the_post_image_attr.diff (2.3 KB) - added by scribu 15 years ago.
Add $attr parameter to the_post_image()
remove_thumbnail.diff (4.0 KB) - added by scribu 15 years ago.
Add a "Remove Thumbnail" link
remove_thumbnail.2.diff (4.0 KB) - added by scribu 15 years ago.
Don't use global $post
referential_integrity.diff (728 bytes) - added by scribu 15 years ago.
page_thumbnails.php.diff (1.5 KB) - added by scribu 15 years ago.
revert_page_scripts.diff (844 bytes) - added by scribu 15 years ago.
use_as_thumbnail.diff (1.7 KB) - added by scribu 15 years ago.
use_as_thumbnail.2.diff (108.5 KB) - added by scribu 15 years ago.
fix_set_thumbnail_js.diff (3.5 KB) - added by scribu 15 years ago.

Download all attachments as: .zip

Change History (45)

#1 @markjaquith
15 years ago

(In [12007]) First pass on canonical post thumbanils. Admin-side GUI only. Theme functions to follow. see #10928

#2 @chrisscott
15 years ago

  • Cc chrisscott added

#3 @markjaquith
15 years ago

[12018] Add some filters, constrain image display in the admin.

#4 @markjaquith
15 years ago

(In [12019]) First pass at canonical post image template functions. see #10928

#5 @markjaquith
15 years ago

(In [12031]) Do not close media thickbox after thumbnail is selected, in case uploads are in progress. see #10928

#6 @scribu
15 years ago

There should be a way for the user to unset the thumbnail.

#7 @scribu
15 years ago

If you wanted to change the class attribute, this is what you'd have to write, with the current hooks:

add_action('begin_fetch_post_image_html', 'begin_post_image_hook');
add_action('end_fetch_post_image_html', 'end_post_image_hook');
function begin_post_image_hook() {
  add_filter('wp_get_attachment_image_attributes', 'post_image_hook');
}
function end_post_image_hook() {
  remove_filter('wp_get_attachment_image_attributes', 'post_image_hook');
}
function post_image_hook($attr) {
  $attr['class'] .= ' alignright';
	
  return $attr;
}

It works, but it's kind of verbose.

@scribu
15 years ago

Add $attr parameter to the_post_image()

@scribu
15 years ago

Add a "Remove Thumbnail" link

#8 @markjaquith
15 years ago

(In [12035]) Allow theme devs to change attrs (like CSS class) of thumbnail images. props scribu. see #10928

@scribu
15 years ago

Don't use global $post

#9 @markjaquith
15 years ago

(In [12036]) Post thumbnail removal functionality (only allowed for replacement before). props scribu. see #10928

#10 @markjaquith
15 years ago

(In [12037]) Remove close TB call that was removed earlier. see #10928

#11 @markjaquith
15 years ago

(In [12039]) Add wp-post-image CSS class to post images. see #10928

#12 @scribu
15 years ago

When deleting an attachment, all post thumbnails from that attachment should be cleared.

See referential_integrity.diff.

#13 @markjaquith
15 years ago

(In [12054]) Delete post thumbnail relationships for deleted attachments. props scribu. see #10928

#14 @scribu
15 years ago

Pages could also use thumbnails. See page_thumbnails.php.diff

#15 @markjaquith
15 years ago

(In [12056]) Allow pages to have thumbnails too. Props scribu. see #10928

#16 @markjaquith
15 years ago

(In [12059]) Only show Use for thumbnail link for image attachments. see #10928

#18 @markjaquith
15 years ago

(In [12064]) pull thumbnail scripts out of Page admin pages. see #10928. props scribu, gracious even in reversion.

#19 @automattor
15 years ago

(In [12065]) Pull thumbnail scripts out of Posts screens too. see #10928

#20 follow-up: @navjotjsingh
15 years ago

There are few problems I find in implementation of Post Thumbnails though. When you upload image, it only shows Insert into post at bottom which should also show Use for Thumbnail. So you will have to first upload image, browse to Media Library and then select Use for Thumbnails. Few clicks can be saved here.

And if a image has been selected as thumbnail and you go to media library second time, Use for Thumbnail is shown against that image too.

#21 in reply to: ↑ 20 @scribu
15 years ago

Replying to navjotjsingh:

There are few problems I find in implementation of Post Thumbnails though. When you upload image, it only shows Insert into post at bottom which should also show Use for Thumbnail. So you will have to first upload image, browse to Media Library and then select Use for Thumbnails. Few clicks can be saved here.

I agree that there should be a way to set a thumbnail without having to go to the Media Library tab.

And if a image has been selected as thumbnail and you go to media library second time, Use for Thumbnail is shown against that image too.

use_as_thumbnail.diff fixes this. Also does a little cleaning.

#22 @scribu
15 years ago

use_as_thumbnail.2.diff moves the "Use as thumbnail" link next to the "Insert into post" button.

#23 @markjaquith
15 years ago

use_as_thumbnail.2.diff removes the ability to set thumbnails from the post gallery.

#24 @markjaquith
15 years ago

Turns out that's not a regression, and this optimizes for the upload > set as thumbnail flow which I think will be more common.

#25 @markjaquith
15 years ago

(In [12081]) Save some clicks and optimize for the Upload, Set as thumbnail flow. props scribu. see #10928

#26 follow-up: @navjotjsingh
15 years ago

Can't say this patch [12081] will save clicks but now has increased one more click to set as thumbnail. Now the Use as Thumbnail appears only when you click Show in Media Library against the Image and that too as a link instead of a nice button? Only the second problem appears to have been fixed from my last post.

And why does Use as Thumbnail changes to Use for Thumbnail on setting a thumbnail? Link should disappear when it gets set as Thumbnail.

#27 in reply to: ↑ 26 @scribu
15 years ago

Replying to navjotjsingh:

Can't say this patch [12081] will save clicks but now has increased one more click to set as thumbnail. Now the Use as Thumbnail appears only when you click Show in Media Library against the Image and that too as a link instead of a nice button? Only the second problem appears to have been fixed from my last post.

Not all clicks are created equal: the previous click involved loading a new tab, which is much slower than expanding a media item. The flow will probably be improved with the new Media UI in a future release.

And why does Use as Thumbnail changes to Use for Thumbnail on setting a thumbnail? Link should disappear when it gets set as Thumbnail.

Yes, this should be fixed.

#28 @scribu
15 years ago

Related: #10992.

#29 @automattor
15 years ago

(In [12111]) thumbnail JS fixes. props scribu. see #10928

#30 @automattor
15 years ago

(In [12134]) Introduce require_if_theme_supports(), move post thumbnails functions to there own include and only included them if the theme supports them. See #10928 and [12132]

#32 @scribu
15 years ago

related: #11196

#33 @ryan
15 years ago

  • Component changed from Media to Post Thumbnails

#34 @ryan
15 years ago

  • Resolution set to fixed
  • Status changed from new to closed

#35 @aaroncampbell
15 years ago

  • Cc aaron@… added
  • Resolution fixed deleted
  • Status changed from closed to reopened

It would be really nice if a plugin could enable support of this as well. For example, I want http://wordpress.org/extend/plugins/featured-content-showcase/ to be able to enable the functionality so I don't have to tell the user to add a line to their theme's functions.php file during installation, but the require_if_theme_supports() call in wp-settings happens too early.

If this should be a different ticket, let me know and I'll open one.

#36 @aaroncampbell
15 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

Sorry, this was my mistake. I moved the command to the plugin and at the same time updated it to use post-images. The site's only on the newest nightly though, so it was still checking post-thumbnails.

Note: See TracTickets for help on using tickets.