Title: WP_Customize_Manager::_validate_header_video
Published: December 7, 2016
Last modified: August 20, 2026

---

# WP_Customize_Manager::_validate_header_video( WP_Error $validity, mixed $value ): mixed

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_customize_manager/_validate_header_video/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/classes/wp_customize_manager/_validate_header_video/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_customize_manager/_validate_header_video/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_customize_manager/_validate_header_video/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_customize_manager/_validate_header_video/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_customize_manager/_validate_header_video/?output_format=md#changelog)

Callback for validating the header_video value.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_customize_manager/_validate_header_video/?output_format=md#description)󠁿

Ensures that the selected video is less than 8MB and provides an error message.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_customize_manager/_validate_header_video/?output_format=md#parameters)󠁿

 `$validity`[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)
required

`$value`mixedrequired

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_customize_manager/_validate_header_video/?output_format=md#return)󠁿

 mixed

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_customize_manager/_validate_header_video/?output_format=md#source)󠁿

    ```php
    public function _validate_header_video( $validity, $value ) {
    	$video = get_attached_file( absint( $value ) );
    	if ( $video ) {
    		$size = filesize( $video );
    		if ( $size > 8 * MB_IN_BYTES ) {
    			$validity->add(
    				'size_too_large',
    				__( 'This video file is too large to use as a header video. Try a shorter video or optimize the compression settings and re-upload a file that is less than 8MB. Or, upload your video to YouTube and link it with the option below.' )
    			);
    		}
    		if ( ! str_ends_with( $video, '.mp4' ) && ! str_ends_with( $video, '.mov' ) ) { // Check for .mp4 or .mov format, which (assuming h.264 encoding) are the only cross-browser-supported formats.
    			$validity->add(
    				'invalid_file_type',
    				sprintf(
    					/* translators: 1: .mp4, 2: .mov */
    					__( 'Only %1$s or %2$s files may be used for header video. Please convert your video file and try again, or, upload your video to YouTube and link it with the option below.' ),
    					'<code>.mp4</code>',
    					'<code>.mov</code>'
    				)
    			);
    		}
    	}
    	return $validity;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-customize-manager.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/class-wp-customize-manager.php#L6095)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/class-wp-customize-manager.php#L6095-L6118)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_customize_manager/_validate_header_video/?output_format=md#related)󠁿

| Uses | Description | 
| [get_attached_file()](https://developer.wordpress.org/reference/functions/get_attached_file/)`wp-includes/post.php` |

Retrieves attached file path based on attachment ID.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [absint()](https://developer.wordpress.org/reference/functions/absint/)`wp-includes/load.php` |

Converts a value to non-negative integer.

  |

[Show 1 more](https://developer.wordpress.org/reference/classes/wp_customize_manager/_validate_header_video/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_customize_manager/_validate_header_video/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_customize_manager/_validate_header_video/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.7.0](https://developer.wordpress.org/reference/since/4.7.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_customize_manager%2F_validate_header_video%2F)
before being able to contribute a note or feedback.