[wp-trac] [WordPress Trac] #37989: Unexpected change to media title behavior in WP 4.6.1

WordPress Trac noreply at wordpress.org
Wed Sep 14 00:56:12 UTC 2016


#37989: Unexpected change to media title behavior in WP 4.6.1
---------------------------+------------------------
 Reporter:  arhenderson63  |       Owner:  joemcgill
     Type:  defect (bug)   |      Status:  accepted
 Priority:  normal         |   Milestone:  4.6.2
Component:  Media          |     Version:  4.6.1
 Severity:  normal         |  Resolution:
 Keywords:  needs-patch    |     Focuses:
---------------------------+------------------------

Comment (by arhenderson63):

 @SergeyBiryukov

 I've tested the workaround; while it's going in the right direction; still
 does not produce clean, usable media titles as were present in 4.6.0 and
 prior.

 * Upload filename:           'Acer ×freemanii 'Jeffersred' (Autumn
 Blaze®); 2½ in.jpg'
 * Pre-WP 4.6.1 WP Title:      Acer ×freemanii 'Jeffersred' (Autumn
 Blaze®); 2½ in
 * WP 4.6.1 title (prepatch):  acer-xfreemanii-jeffersred-autumn-blaze-2%c2
 %bd-in
 * WP 4.6.1 title (w/ patch):  Acer-×freemanii-Jeffersred-Autumn-Blaze®-2½-
 in.jpg

 So capitalisation is now retained as are certain higher-order ASCII
 characters.  But dashes are still swapped for spaces, quotes and
 parenthesis are dropped and the file extension is now appended to the
 title.  It appears that this is just a different sanitised string; the
 original media filename should be passed to the WP title field as
 presented, not sanitised.

 Replying to [comment:11 SergeyBiryukov]:
 > A workaround:
 > {{{
 > function wp37989_fix_encoded_attachment_titles( $data, $postarr ) {
 >       $basename = pathinfo( $postarr['file'], PATHINFO_BASENAME );
 >
 >       $data['post_title'] = sanitize_text_field( $basename );
 >
 >       return $data;
 > }
 > add_filter( 'wp_insert_attachment_data',
 'wp37989_fix_encoded_attachment_titles', 10, 2 );
 > }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/37989#comment:16>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list