BP_Attachment_Avatar::validate_upload( array $file = array() )

Avatar specific rules.


Description Description

Adds an error if the avatar size or type don’t match BuddyPress needs. The error code is the index of $upload_error_strings.


Parameters Parameters

$file

(Optional) the temporary file attributes (before it has been moved).

Default value: array()


Top ↑

Return Return

(array) the file with extra errors if needed.


Top ↑

Source Source

File: bp-core/classes/class-bp-attachment-avatar.php

	public function validate_upload( $file = array() ) {
		// Bail if already an error.
		if ( ! empty( $file['error'] ) ) {
			return $file;
		}

		// File size is too big.
		if ( ! bp_core_check_avatar_size( array( 'file' => $file ) ) ) {
			$file['error'] = 9;

		// File is of invalid type.
		} elseif ( ! bp_core_check_avatar_type( array( 'file' => $file ) ) ) {
			$file['error'] = 10;
		}

		// Return with error code attached.
		return $file;
	}

Top ↑

Changelog Changelog

Changelog
Version Description
2.3.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.