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

SimplePie_Enclosure::embed() public WP 1.0

Embed the enclosure using Javascript

$options is an array or comma-separated key:value string, with the following properties:

  • alt (string): Alternate content for when an end-user does not have
    the appropriate handler installed or when a file type is
    unsupported. Can be any text or HTML. Defaults to blank.
  • altclass (string): If a file type is unsupported, the end-user will
    see the alt text (above) linked directly to the content. That link
    will have this value as its class name. Defaults to blank.
  • audio (string): This is an image that should be used as a
    placeholder for audio files before they're loaded (QuickTime-only).
    Can be any relative or absolute URL. Defaults to blank.
  • bgcolor (string): The background color for the media, if not
    already transparent. Defaults to `#ffffff`.
  • height (integer): The height of the embedded media. Accepts any
    numeric pixel value (such as `360`) or `auto`. Defaults to `auto`,
    and it is recommended that you use this default.
  • loop (boolean): Do you want the media to loop when it's done?
    Defaults to `false`.
  • mediaplayer (string): The location of the included
    `mediaplayer.swf` file. This allows for the playback of Flash Video
    (`.flv`) files, and is the default handler for non-Odeo MP3's.
    Defaults to blank.
  • video (string): This is an image that should be used as a
    placeholder for video files before they're loaded (QuickTime-only).
    Can be any relative or absolute URL. Defaults to blank.
  • width (integer): The width of the embedded media. Accepts any
    numeric pixel value (such as `480`) or `auto`. Defaults to `auto`,
    and it is recommended that you use this default.
  • widescreen (boolean): Is the enclosure widescreen or standard?
    This applies only to video enclosures, and will automatically resize
    the content appropriately.  Defaults to `false`, implying 4:3 mode.

Note: Non-widescreen (4:3) mode with width and height set to auto will default to 480x360 video resolution. Widescreen (16:9) mode with width and height set to auto will default to 480x270 video resolution.

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

Хуков нет.

Возвращает

Строку. HTML string to output

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

$SimplePie_Enclosure = new SimplePie_Enclosure();
$SimplePie_Enclosure->embed( $options, $native );
$options(массив/строка)
Comma-separated key:value list, or array
По умолчанию: ''
$native(true/false)
Use <embed>
По умолчанию: false

Код SimplePie_Enclosure::embed() WP 5.5.3

<?php
public function embed($options = '', $native = false)
{
	// Set up defaults
	$audio = '';
	$video = '';
	$alt = '';
	$altclass = '';
	$loop = 'false';
	$width = 'auto';
	$height = 'auto';
	$bgcolor = '#ffffff';
	$mediaplayer = '';
	$widescreen = false;
	$handler = $this->get_handler();
	$type = $this->get_real_type();

	// Process options and reassign values as necessary
	if (is_array($options))
	{
		extract($options);
	}
	else
	{
		$options = explode(',', $options);
		foreach($options as $option)
		{
			$opt = explode(':', $option, 2);
			if (isset($opt[0], $opt[1]))
			{
				$opt[0] = trim($opt[0]);
				$opt[1] = trim($opt[1]);
				switch ($opt[0])
				{
					case 'audio':
						$audio = $opt[1];
						break;

					case 'video':
						$video = $opt[1];
						break;

					case 'alt':
						$alt = $opt[1];
						break;

					case 'altclass':
						$altclass = $opt[1];
						break;

					case 'loop':
						$loop = $opt[1];
						break;

					case 'width':
						$width = $opt[1];
						break;

					case 'height':
						$height = $opt[1];
						break;

					case 'bgcolor':
						$bgcolor = $opt[1];
						break;

					case 'mediaplayer':
						$mediaplayer = $opt[1];
						break;

					case 'widescreen':
						$widescreen = $opt[1];
						break;
				}
			}
		}
	}

	$mime = explode('/', $type, 2);
	$mime = $mime[0];

	// Process values for 'auto'
	if ($width === 'auto')
	{
		if ($mime === 'video')
		{
			if ($height === 'auto')
			{
				$width = 480;
			}
			elseif ($widescreen)
			{
				$width = round((intval($height)/9)*16);
			}
			else
			{
				$width = round((intval($height)/3)*4);
			}
		}
		else
		{
			$width = '100%';
		}
	}

	if ($height === 'auto')
	{
		if ($mime === 'audio')
		{
			$height = 0;
		}
		elseif ($mime === 'video')
		{
			if ($width === 'auto')
			{
				if ($widescreen)
				{
					$height = 270;
				}
				else
				{
					$height = 360;
				}
			}
			elseif ($widescreen)
			{
				$height = round((intval($width)/16)*9);
			}
			else
			{
				$height = round((intval($width)/4)*3);
			}
		}
		else
		{
			$height = 376;
		}
	}
	elseif ($mime === 'audio')
	{
		$height = 0;
	}

	// Set proper placeholder value
	if ($mime === 'audio')
	{
		$placeholder = $audio;
	}
	elseif ($mime === 'video')
	{
		$placeholder = $video;
	}

	$embed = '';

	// Flash
	if ($handler === 'flash')
	{
		if ($native)
		{
			$embed .= "<embed src=\"" . $this->get_link() . "\" pluginspage=\"http://adobe.com/go/getflashplayer\" type=\"$type\" quality=\"high\" width=\"$width\" height=\"$height\" bgcolor=\"$bgcolor\" loop=\"$loop\"></embed>";
		}
		else
		{
			$embed .= "<script type='text/javascript'>embed_flash('$bgcolor', '$width', '$height', '" . $this->get_link() . "', '$loop', '$type');</script>";
		}
	}

	// Flash Media Player file types.
	// Preferred handler for MP3 file types.
	elseif ($handler === 'fmedia' || ($handler === 'mp3' && $mediaplayer !== ''))
	{
		$height += 20;
		if ($native)
		{
			$embed .= "<embed src=\"$mediaplayer\" pluginspage=\"http://adobe.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" quality=\"high\" width=\"$width\" height=\"$height\" wmode=\"transparent\" flashvars=\"file=" . rawurlencode($this->get_link().'?file_extension=.'.$this->get_extension()) . "&autostart=false&repeat=$loop&showdigits=true&showfsbutton=false\"></embed>";
		}
		else
		{
			$embed .= "<script type='text/javascript'>embed_flv('$width', '$height', '" . rawurlencode($this->get_link().'?file_extension=.'.$this->get_extension()) . "', '$placeholder', '$loop', '$mediaplayer');</script>";
		}
	}

	// QuickTime 7 file types.  Need to test with QuickTime 6.
	// Only handle MP3's if the Flash Media Player is not present.
	elseif ($handler === 'quicktime' || ($handler === 'mp3' && $mediaplayer === ''))
	{
		$height += 16;
		if ($native)
		{
			if ($placeholder !== '')
			{
				$embed .= "<embed type=\"$type\" style=\"cursor:hand; cursor:pointer;\" href=\"" . $this->get_link() . "\" src=\"$placeholder\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"false\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\"></embed>";
			}
			else
			{
				$embed .= "<embed type=\"$type\" style=\"cursor:hand; cursor:pointer;\" src=\"" . $this->get_link() . "\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"true\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\"></embed>";
			}
		}
		else
		{
			$embed .= "<script type='text/javascript'>embed_quicktime('$type', '$bgcolor', '$width', '$height', '" . $this->get_link() . "', '$placeholder', '$loop');</script>";
		}
	}

	// Windows Media
	elseif ($handler === 'wmedia')
	{
		$height += 45;
		if ($native)
		{
			$embed .= "<embed type=\"application/x-mplayer2\" src=\"" . $this->get_link() . "\" autosize=\"1\" width=\"$width\" height=\"$height\" showcontrols=\"1\" showstatusbar=\"0\" showdisplay=\"0\" autostart=\"0\"></embed>";
		}
		else
		{
			$embed .= "<script type='text/javascript'>embed_wmedia('$width', '$height', '" . $this->get_link() . "');</script>";
		}
	}

	// Everything else
	else $embed .= '<a href="' . $this->get_link() . '" class="' . $altclass . '">' . $alt . '</a>';

	return $embed;
}