[wp-trac] [WordPress Trac] #11895: Allow more specific image size editing
WordPress Trac
noreply at wordpress.org
Sun Feb 22 21:02:16 UTC 2015
#11895: Allow more specific image size editing
------------------------------------------------+--------------------------
Reporter: frankgroeneveld | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: Future
Component: Media | Release
Severity: normal | Version:
Keywords: has-patch dev-feedback ui-feedback | Resolution:
| Focuses: ui
------------------------------------------------+--------------------------
Changes (by bradt):
* keywords: has-patch => has-patch dev-feedback ui-feedback
Comment:
I've taken a first crack at this.
Because `add_image_size()` doesn't require labels (like
`register_post_type()` for example), the `image_size_names_choose` filter
is used elsewhere in core to get labels for custom image sizes. For
example, the form to insert an image into a post uses it to build a drop
down of the available image sizes you can insert into a post. I've used
this `image_size_names_choose` filter here.
Adding your own filter, you can enable your custom image sizes to be in
the list. For example, if you had a custom image size named "homepage-
thumb", you could add it to the list of checkboxes with the following:
{{{
add_filter( 'image_size_names_choose', function( $names ) {
$names['homepage-thumb'] = __( 'Homepage Thumbnail', 'your-domain'
);
return $names;
} );
}}}
Of course, this filter would also make "Homepage Thumbnail" show up in the
drop down when inserting an image into a post, which you may not want. So
we should probably have our own filter here to define the labels for
editing images.
Also, if you don't define a filter for your custom image size, they won't
appear in the checkbox list and so won't be editable.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/11895#comment:20>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list