[wp-trac] [WordPress Trac] #17215: Featured images for post types without editor can't be used by other types

WordPress Trac wp-trac at lists.automattic.com
Fri May 20 15:22:26 UTC 2011


#17215: Featured images for post types without editor can't be used by other types
-----------------------------+------------------------------
 Reporter:  jleuze           |       Owner:
     Type:  defect (bug)     |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Post Thumbnails  |     Version:  3.1.1
 Severity:  normal           |  Resolution:
 Keywords:                   |
-----------------------------+------------------------------

Comment (by jmkprime):

 I ran into exactly the same problem that jleuze describes.

 The actual code instance of it appears to come from the default $args set
 in the get_media_item() function in wp-admin/includes/media.php. The
 appearance of the button is controlled by the 'send' part of $args and
 that is set to positive if the attachment is attached to a post type which
 supports the 'editor'. This appears in the get_media_item function as

 {{{ 'send' => $post->post_parent ? post_type_supports( get_post_type(
 $post->post_parent ), 'editor' ) : true }}}

 That assumes that an attached image will only ever be inserted into a post
 with the same post-type as its parent. A better check would be to test
 whether the post type of the currently edited post supports the 'editor'.
 For example:

 {{{ 'send' => $_REQUEST['post_id'] ? post_type_supports( get_post_type(
 $_REQUEST['post_id'] ), 'editor' ) : false }}}

 That is - if the currently edited post is identified and that identified
 post supports the editor then show the insert button otherwise there is
 nowhere to send the image so default to not showing the button.

 A plug-in level work around would be to use the 'get_media_item_args'
 filter.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/17215#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list