WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 20 months ago

#19257 new enhancement

Allow post types to override the phrase "Featured image"

Reported by: johnbillion Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.0
Component: Posts, Post Types Keywords: has-patch
Focuses: Cc:

Description

It would be nice if the phrase "Featured image" could be filtered so it could be tailored to fit its post type. For example:

  • A post type of 'person' could set it to 'Mugshot'
  • A post type of 'album' could set it to 'Cover art'
  • A post type of 'company' could set it to 'Company Logo'

Patch upcoming.

Attachments (1)

19257.patch (7.7 KB) - added by johnbillion 2 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 follow-up: nacin2 years ago

Filtering the text itself is rather easy (if hacky), but it would be especially nice if set_post_thumbnail_size() and add_image_size() could be drilled down to individual post types.

See #18057 (patch on #18027) for something similar - the ability to define a "usage" for a featured image.

johnbillion2 years ago

comment:2 follow-up: johnbillion2 years ago

  • Keywords has-patch added

Here's my take on this. The attached patch adds three new labels to the post type objects. The defaults are:

  • featured_image => 'Featured Image'
  • set_featured_image => 'Set featured image'
  • remove_featured_image => 'Remove featured image'
  • use_featured_image => 'Use as featured image'

These strings are used in the featured image meta box and in the media lightbox.

A custom post type would set its own labels for featured images like so:

register_post_type( 'company', array(
	'labels' => array(
		'featured_image' => 'Company Logo',
		'set_featured_image' => 'Set company logo',
		'remove_featured_image' => 'Remove company logo',
		'use_featured_image' => 'Use as company logo'
	)
) );

comment:3 in reply to: ↑ 2 DrewAPicture2 years ago

  • Cc xoodrew@… added

Replying to johnbillion:

A custom post type would set its own labels for featured images like so:

register_post_type( 'company', array(
	'labels' => array(
		'featured_image' => 'Company Logo',
		'set_featured_image' => 'Set company logo',
		'remove_featured_image' => 'Remove company logo',
		'use_featured_image' => 'Use as company logo'
	)
) );

+1 for this. This would be very helpful for many of my projects.

comment:4 nacin2 years ago

  • Version changed from 3.3 to 3.0

comment:5 jane2 years ago

  • Milestone changed from Awaiting Review to Future Release

Sounds good to me.

comment:6 johnbillion20 months ago

I know it's late but this would be nice to see in 3.5.

comment:7 JustinSainton20 months ago

+1 for the idea - not sure on the implementation of adding the labels vs. filters. But this would be super helpful. Currently filtering via gettext - which is hacky (like nacin said).

comment:8 in reply to: ↑ 1 nacin20 months ago

Replying to nacin:

Filtering the text itself is rather easy (if hacky), but it would be especially nice if set_post_thumbnail_size() and add_image_size() could be drilled down to individual post types.

I think this should wait for this to occur. Filtering via gettext at least works. Adding an API for post types to modify the *labels* is completely lame if they can't do post-type-specific featured images.

The media, image, and thumbnail work in 3.5 should enable this to happen in 3.6 (probably not sooner).

Note: See TracTickets for help on using tickets.