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

Cover image specific rules.


Description Description

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


Top ↑

Parameters Parameters

$file

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

Default value: array()


Top ↑

Return Return

(array) $file The file with extra errors if needed.


Source Source

File: bp-core/classes/class-bp-attachment-cover-image.php

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

		// File size is too big.
		if ( isset( $file['size'] ) && ( $file['size'] > $this->original_max_filesize ) ) {
			$file['error'] = 11;

		// File is of invalid type.
		} elseif ( isset( $file['tmp_name'] ) && isset( $file['name'] ) && ! bp_attachments_check_filetype( $file['tmp_name'], $file['name'], bp_attachments_get_allowed_mimes( 'cover_image' ) ) ) {
			$file['error'] = 12;
		}

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


Top ↑

Changelog Changelog

Changelog
Version Description
2.4.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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