image_add_caption_text
Filter HookDescription
Filters the caption text. Note: If the caption text is empty, the caption shortcode will not be appended to the image HTML when inserted into the editor. Passing an empty value also prevents the {@see 'image_add_caption_shortcode'} Filters from being evaluated at the end of image_add_caption().Hook Information
File Location |
wp-admin/includes/media.php
View on GitHub
|
Hook Type | Filter |
Line Number | 204 |
Hook Parameters
Type | Name | Description |
---|---|---|
string
|
$caption
|
The original caption text. |
int
|
$id
|
The attachment ID. |
Usage Examples
Basic Usage
<?php
// Hook into image_add_caption_text
add_filter('image_add_caption_text', 'my_custom_filter', 10, 2);
function my_custom_filter($caption, $id) {
// Your custom filtering logic here
return $caption;
}
Source Code Context
wp-admin/includes/media.php:204
- How this hook is used in WordPress core
<?php
199 * @since 4.1.0
200 *
201 * @param string $caption The original caption text.
202 * @param int $id The attachment ID.
203 */
204 $caption = apply_filters( 'image_add_caption_text', $caption, $id );
205
206 /**
207 * Filters whether to disable captions.
208 *
209 * Prevents image captions from being appended to image HTML when inserted into the editor.
PHP Documentation
<?php
/**
* Filters the caption text.
*
* Note: If the caption text is empty, the caption shortcode will not be appended
* to the image HTML when inserted into the editor.
*
* Passing an empty value also prevents the {@see 'image_add_caption_shortcode'}
* Filters from being evaluated at the end of image_add_caption().
*
* @since 4.1.0
*
* @param string $caption The original caption text.
* @param int $id The attachment ID.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-admin/includes/media.php
Related Hooks
Related hooks will be displayed here in future updates.