WordPress at Your Fingertips
function is not described

getID3::GetFileFormat() public WP 1.0

{} It's a method of the class: getID3{}

No Hooks.




$getID3 = new getID3();
$getID3->GetFileFormat( $filedata, $filename );
$filedata(string) (required) (passed by reference — &)
Default: ''

Code of getID3::GetFileFormat() WP 5.9

public function GetFileFormat(&$filedata, $filename='') {
	// this function will determine the format of a file based on usually
	// the first 2-4 bytes of the file (8 bytes for PNG, 16 bytes for JPG,
	// and in the case of ISO CD image, 6 bytes offset 32kb from the start
	// of the file).

	// Identify file format - loop through $format_info and detect with reg expr
	foreach ($this->GetFileFormatArray() as $format_name => $info) {
		// The /s switch on preg_match() forces preg_match() NOT to treat
		// newline (0x0A) characters as special chars but do a binary match
		if (!empty($info['pattern']) && preg_match('#'.$info['pattern'].'#s', $filedata)) {
			$info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
			return $info;

	if (preg_match('#\\.mp[123a]$#i', $filename)) {
		// Too many mp3 encoders on the market put garbage in front of mpeg files
		// use assume format on these if format detection failed
		$GetFileFormatArray = $this->GetFileFormatArray();
		$info = $GetFileFormatArray['mp3'];
		$info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
		return $info;
	} elseif (preg_match('#\\.cue$#i', $filename) && preg_match('#FILE "[^"]+" (BINARY|MOTOROLA|AIFF|WAVE|MP3)#', $filedata)) {
		// there's not really a useful consistent "magic" at the beginning of .cue files to identify them
		// so until I think of something better, just go by filename if all other format checks fail
		// and verify there's at least one instance of "TRACK xx AUDIO" in the file
		$GetFileFormatArray = $this->GetFileFormatArray();
		$info = $GetFileFormatArray['cue'];
		$info['include']   = 'module.'.$info['group'].'.'.$info['module'].'.php';
		return $info;

	return false;