BP_Attachment_Cover_Image::generate_filename( string $file = '' )

Generate a filename for the cover photo.

Description

Parameters

$file

(string) (Optional) The absolute path to the file.

Default value: ''

Return

(false|string) $value The absolute path to the new file name.

Source

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

	public function generate_filename( $file = '' ) {
		if ( empty( $file ) || ! file_exists( $file ) ) {
			return false;
		}

		$info = pathinfo( $file );
		$ext  = strtolower( $info['extension'] );
		$name = wp_unique_filename( $info['dirname'], uniqid() . "-bp-cover-image.$ext" );

		return trailingslashit( $info['dirname'] ) . $name;
	}

Changelog

Changelog
Version Description
BuddyPress 2.4.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.