WordPress.org

Make WordPress Core


Ignore:
Timestamp:
06/29/2016 05:28:00 PM (5 years ago)
Author:
joemcgill
Message:

Post Thumbnails: Add helper functions for attachment captions.

This adds three new functions for getting/displaying attachment captions:

  • wp_get_attachment_caption - Retrieves a caption for a specific attachment.
  • get_the_post_thumbnail_caption() - Returns the post thumbnail caption.
  • the_post_thumbnail_caption() - Displays the post thumbnail caption.

These are helpful for displaying a caption associated with an image directly
in a template, rather than using the caption shortcode.

This also introduces two new filters:

  • wp_get_attachment_caption - Filters the value of wp_get_attachment_caption().
  • the_post_thumbnail_caption - Filters the display of the post thumbnail caption.

the_post_thumbnail_caption() is automatically filtered by wptexturize(),
convert_smilies(), and convert_chars() in wp-includes/default-filters.php.

Props flixos90, joemcgill.
Fixes #12235.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/default-filters.php

    r37908 r37915  
    143143add_filter( 'the_excerpt',     'shortcode_unautop');
    144144add_filter( 'get_the_excerpt', 'wp_trim_excerpt'  );
     145
     146add_filter( 'the_post_thumbnail_caption', 'wptexturize'     );
     147add_filter( 'the_post_thumbnail_caption', 'convert_smilies' );
     148add_filter( 'the_post_thumbnail_caption', 'convert_chars'   );
    145149
    146150add_filter( 'comment_text', 'wptexturize'            );
Note: See TracChangeset for help on using the changeset viewer.