[wp-trac] [WordPress Trac] #12235: Display caption with the_post_thumbnail

WordPress Trac noreply at wordpress.org
Wed Jun 29 15:01:37 UTC 2016


#12235: Display caption with the_post_thumbnail
---------------------------------------------+-----------------------
 Reporter:  hd-J                             |       Owner:  flixos90
     Type:  enhancement                      |      Status:  assigned
 Priority:  normal                           |   Milestone:  4.6
Component:  Post Thumbnails                  |     Version:  2.9
 Severity:  normal                           |  Resolution:
 Keywords:  has-patch has-unit-tests commit  |     Focuses:
---------------------------------------------+-----------------------

Comment (by joemcgill):

 I think we're really close, but after getting some feedback from a few
 other developers, I wanted to suggest a few additional changes before this
 goes in.

 First, when the caption is left blank, @boonebgorges suggested that we
 should probably return an empty string rather than returning `false` and I
 tend to agree. I assume you were following the lead of
 `wp_get_attachment_url()` there, but I think in this case, we don’t need
 to be as strict.

 Second, @ocean90  suggested that we really don’t need to use `wp_kses()`
 on `the_post_thumbnail_caption()` because it’s essentially the same as
 `the_excerpt()` in this context, rather than in `img_caption_shortcode()`
 where we're parsing post data inserted into a shortcode.

 That said, we should also run some of the text formatting filters that
 automatically run on `the_excerpt()`. I’m thinking `wptexturize()`,
 `convert_smilies()`, and `convert_chars()`. I’m 50/50 on whether we should
 leave off `wpautop()`. The input we accept is a multi-line textarea, but
 the current behavior of captions generated by the shortcode is to not
 automatically convert to paragraphs, so I lean towards leaving off for
 consistency there. We can always reevaluate that decision if we want to
 automatically convert breaks to paragraphs in captions later, as well.

 [attachment:12235.5.diff] returns an empty string when the caption is left
 blank and updates the tests to account for the change. This also removes
 the `wp_kses()` call from `the_post_thumbnail_caption()` and adds the new
 filters to `wp-includes/default-filters.php`.

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


More information about the wp-trac mailing list