apply_filters( 'disable_captions', bool $bool )
- Since
- 2.6.0
Filters whether to disable captions.
Description
Prevents image captions from being appended to image HTML when inserted into the editor.
Compatibility
- WordPress
- since 2.6.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Parameters
$boolbool- Whether to disable appending captions. Returning true from the filter will disable captions. Default empty string.
Where this hook fires · 8
wp-admin/includes/media.php:216image_add_caption()wp-admin/includes/media.php:2467media_upload_type_url_form()wp-admin/includes/media.php:2950wp_media_insert_url_form()wp-includes/class-wp-editor.php:567_WP_Editors::editor_settings()wp-includes/media-template.php:1081wp_print_media_templates()wp-includes/media-template.php:1144wp_print_media_templates()wp-includes/media.php:4965wp_enqueue_media()wp-includes/script-loader.php:559wp_tinymce_inline_scripts()
Source code
* * @since 2.6.0 * * @param bool $bool Whether to disable appending captions. Returning true from the filter * will disable captions. Default empty string. */ if ( empty( $caption ) || apply_filters( 'disable_captions', '' ) ) { return $html; } $id = ( 0 < (int) $id ) ? 'attachment_' . $id : ''; if ( ! preg_match( '/width=["\']([0-9]+)/', $html, $matches ) ) {Changelog
Introduced in 2.6.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.0.4 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
- Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.