Opened 13 years ago
Closed 9 years ago
#19257 closed enhancement (fixed)
Allow post types to override the phrase "Featured image"
Reported by: | johnbillion | Owned by: | johnbillion |
---|---|---|---|
Milestone: | 4.3 | Priority: | normal |
Severity: | normal | Version: | 3.0 |
Component: | Posts, Post Types | Keywords: | |
Focuses: | ui, administration | 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 (4)
Change History (29)
#2
follow-up:
↓ 3
@
13 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' ) ) );
#3
in reply to:
↑ 2
@
13 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.
#7
@
12 years 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).
#8
in reply to:
↑ 1
@
12 years 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).
#9
@
9 years ago
- Focuses ui administration added
- Keywords needs-refresh good-first-bug added
This a pretty cool idea and would be useful for many plugins. Patch needs a refresh
#10
@
9 years ago
- Keywords needs-testing needs-unit-tests added; needs-refresh good-first-bug removed
19257-2.patch is a refreshed and working patch.
This ticket was mentioned in Slack in #core by johnbillion. View the logs.
9 years ago
#14
@
9 years ago
- Milestone changed from Future Release to 4.3
- Owner changed from chriscct7 to johnbillion
- Status changed from reviewing to accepted
#15
@
9 years ago
@johnbillion I started reviewing this on Wednesday, but I got sidetracked and I took yesterday off. I'll review it today in the next couple hours.
#16
@
9 years ago
- Keywords needs-testing removed
Did a review and everything looks correct. There were some extra white spaces and the patch didn't apply clean anymore, so I refreshed it. As well, There were missing param docs in get_post_type_labels
that I added in the process. Should be ready to go.
#18
@
9 years ago
- Keywords needs-patch added; has-patch removed
- Resolution fixed deleted
- Status changed from closed to reopened
r32673 is causing notices on the Media screen:
Trying to get property of non-object in ~/wp-includes/media.php on line 3011
Looks like $post
at that point can be null.
#20
@
9 years ago
[32673] broke make/core: get_post_types()
does not exist in wp-admin/load-scripts.php
(only exists if SCRIPT_DEBUG
is true).
#21
@
9 years ago
It looks like WPSetAsThumbnail()
is never used in post-3.5 media UI and is only kept for back compat, so this part can be reverted.
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.