/**
  * Cover image specific rules.
  *
  * 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.
  *
  * @since 2.4.0
  *
  * @param  array $file the temporary file attributes (before it has been moved).
  *
  * @return array the file with extra errors if needed.
  */
 public function validate_upload($file = array())
 {
     // Bail if already an error
     if (!empty($file['error'])) {
         return $file;
     }
     // File size is too big
     if ($file['size'] > $this->original_max_filesize) {
         $file['error'] = 11;
         // File is of invalid type
     } elseif (!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;
 }
Exemplo n.º 2
0
/**
 * Does the current avatar upload have an allowed file type?
 *
 * Permitted file types are JPG, GIF and PNG.
 *
 * @param array $file The $_FILES array.
 *
 * @return bool True if the file extension is permitted, otherwise false.
 */
function bp_core_check_avatar_type($file)
{
    return bp_attachments_check_filetype($file['file']['tmp_name'], $file['file']['name'], bp_core_get_allowed_avatar_mimes());
}