WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Платформа для конвертации и монетизации трафика
функция не описана

SimplePie_Enclosure::get_real_type() public WP 1.0

Get the real media type

Often, feeds lie to us, necessitating a bit of deeper inspection. This converts types to their canonical representations based on the file extension

{} Это метод класса: SimplePie_Enclosure{}

Хуков нет.

Возвращает

Строку. MIME type

Использование

$SimplePie_Enclosure = new SimplePie_Enclosure();
$SimplePie_Enclosure->get_real_type( $find_handler );
$find_handler(true/false)
Internal use only, use {@see get_handler()} instead
По умолчанию: false

Заметки

  • Смотрите: get_type()

Код SimplePie_Enclosure::get_real_type() WP 5.5.3

<?php
public function get_real_type($find_handler = false)
{
	// Mime-types by handler.
	$types_flash = array('application/x-shockwave-flash', 'application/futuresplash'); // Flash
	$types_fmedia = array('video/flv', 'video/x-flv','flv-application/octet-stream'); // Flash Media Player
	$types_quicktime = array('audio/3gpp', 'audio/3gpp2', 'audio/aac', 'audio/x-aac', 'audio/aiff', 'audio/x-aiff', 'audio/mid', 'audio/midi', 'audio/x-midi', 'audio/mp4', 'audio/m4a', 'audio/x-m4a', 'audio/wav', 'audio/x-wav', 'video/3gpp', 'video/3gpp2', 'video/m4v', 'video/x-m4v', 'video/mp4', 'video/mpeg', 'video/x-mpeg', 'video/quicktime', 'video/sd-video'); // QuickTime
	$types_wmedia = array('application/asx', 'application/x-mplayer2', 'audio/x-ms-wma', 'audio/x-ms-wax', 'video/x-ms-asf-plugin', 'video/x-ms-asf', 'video/x-ms-wm', 'video/x-ms-wmv', 'video/x-ms-wvx'); // Windows Media
	$types_mp3 = array('audio/mp3', 'audio/x-mp3', 'audio/mpeg', 'audio/x-mpeg'); // MP3

	if ($this->get_type() !== null)
	{
		$type = strtolower($this->type);
	}
	else
	{
		$type = null;
	}

	// If we encounter an unsupported mime-type, check the file extension and guess intelligently.
	if (!in_array($type, array_merge($types_flash, $types_fmedia, $types_quicktime, $types_wmedia, $types_mp3)))
	{
		switch (strtolower($this->get_extension()))
		{
			// Audio mime-types
			case 'aac':
			case 'adts':
				$type = 'audio/acc';
				break;

			case 'aif':
			case 'aifc':
			case 'aiff':
			case 'cdda':
				$type = 'audio/aiff';
				break;

			case 'bwf':
				$type = 'audio/wav';
				break;

			case 'kar':
			case 'mid':
			case 'midi':
			case 'smf':
				$type = 'audio/midi';
				break;

			case 'm4a':
				$type = 'audio/x-m4a';
				break;

			case 'mp3':
			case 'swa':
				$type = 'audio/mp3';
				break;

			case 'wav':
				$type = 'audio/wav';
				break;

			case 'wax':
				$type = 'audio/x-ms-wax';
				break;

			case 'wma':
				$type = 'audio/x-ms-wma';
				break;

			// Video mime-types
			case '3gp':
			case '3gpp':
				$type = 'video/3gpp';
				break;

			case '3g2':
			case '3gp2':
				$type = 'video/3gpp2';
				break;

			case 'asf':
				$type = 'video/x-ms-asf';
				break;

			case 'flv':
				$type = 'video/x-flv';
				break;

			case 'm1a':
			case 'm1s':
			case 'm1v':
			case 'm15':
			case 'm75':
			case 'mp2':
			case 'mpa':
			case 'mpeg':
			case 'mpg':
			case 'mpm':
			case 'mpv':
				$type = 'video/mpeg';
				break;

			case 'm4v':
				$type = 'video/x-m4v';
				break;

			case 'mov':
			case 'qt':
				$type = 'video/quicktime';
				break;

			case 'mp4':
			case 'mpg4':
				$type = 'video/mp4';
				break;

			case 'sdv':
				$type = 'video/sd-video';
				break;

			case 'wm':
				$type = 'video/x-ms-wm';
				break;

			case 'wmv':
				$type = 'video/x-ms-wmv';
				break;

			case 'wvx':
				$type = 'video/x-ms-wvx';
				break;

			// Flash mime-types
			case 'spl':
				$type = 'application/futuresplash';
				break;

			case 'swf':
				$type = 'application/x-shockwave-flash';
				break;
		}
	}

	if ($find_handler)
	{
		if (in_array($type, $types_flash))
		{
			return 'flash';
		}
		elseif (in_array($type, $types_fmedia))
		{
			return 'fmedia';
		}
		elseif (in_array($type, $types_quicktime))
		{
			return 'quicktime';
		}
		elseif (in_array($type, $types_wmedia))
		{
			return 'wmedia';
		}
		elseif (in_array($type, $types_mp3))
		{
			return 'mp3';
		}

		return null;
	}

	return $type;
}