opencontent / ocembed-ls
Opencontent oEmbed操作符
Requires
README
oEmbed 是一种允许在第三方网站上嵌入URL表示的格式。
oEmbed是为了避免需要从要嵌入媒体的网站复制和粘贴HTML而设计的。它支持视频、图像、文本等。
此eZ扩展(基于WordPress oemabed实现)通过一些模板操作符提供了oEmbed简单嵌入功能。
要求
- eZP >= 4.X 或 5.X(仅在运行Legacy Stack时)
安装
启用扩展;清除所有缓存
预安装的嵌入提供商
- blip.tv
- DailyMotion
- Flickr
- FunnyOrDie.com
- Hulu
- Photobucklet
- PollDaddy
- Qik
- Revision3
- Scribd
- Sideshare
- SmugMug
- Ustream
- Viddler
- Vimeo
- Wordpress.tv
- YouTube
- Google Video
您可以通过创建一个实现oEmbedProviderInterface的PHP类并在ocembed.ini中添加oEmbedProviders[]来添加自己的处理器。
可用的模板操作符
autoembed( mixed $separator, hash $parameters )
打印oEmbed响应的HTML值。
不需要separator
和parameters
变量。
separator
值可以是字符串或数组。默认separator
值为array( '<div class="text-center">', '</div>' )
parameters
值必须是一个数组,并覆盖默认ocembed.ini的宽度和高度参数[OCEmbedSettings].EmbedDefaults。
示例
{"http://www.slideshare.net/gggeek/ezpublish-meets-simfony2-phpday2013"|autoembed( array( '<div class="media-embed">', '</div>' ), hash( 'width', '425', 'height', '355' ) )}
示例返回(不带HTML注释)
<!-- separator --> <div class="media-embed"> <!-- start of result of oembed fetch --> <object width="425" height="355" id="__sse21389517"> <param value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=sf2ezpphpday2013-130518043919-phpapp01&stripped_title=ezpublish-meets-simfony2-phpday2013&userName=gggeek" name="movie"> <param value="true" name="allowFullScreen"> <param value="always" name="allowScriptAccess"> <param value="transparent" name="wmode"> <embed width="425" height="355" wmode="transparent" allowfullscreen="true" allowscriptaccess="always" type="application/x-shockwave-flash" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=sf2ezpphpday2013-130518043919-phpapp01&stripped_title=ezpublish-meets-simfony2-phpday2013&userName=gggeek" name="__sse21389517"> </object> <!-- end of result of oembed fetch --> <!-- end separator --> </div>
此操作符用于此扩展中包含的eztext.tpl和ezxmltext.tpl覆盖模板
{* ocembed/design/standard/templates/content/datatype/view/eztext.tpl *} {$attribute.content.output.output_text|autoembed()}
search_embed()
返回在传入文本中找到的所有可嵌入链接。
示例
{def $test = $my_long_text_full_of_links|search_embed()}
返回一个包含可嵌入URL的数组。
get_oembed_object( string $url, hash $parameters )
返回oEmbed响应
必须提供url
参数,并且它必须是一个“oembeddable”URL。
parameters
值必须是一个数组,并覆盖默认ocembed.ini的宽度和高度参数[OCEmbedSettings].EmbedDefaults。
示例
{def $test = get_oembed_object("http://www.slideshare.net/gggeek/ezpublish-meets-simfony2-phpday2013")}
$test变量包含一个包含oembed响应对象的关联数组。
缓存数据
如果启用了ocembed.ini [OCEmbedSettings] Cache
,则所有ocembed结果都存储在ezsite_data表中的“oembed_cached_data”键下。要清除该缓存,可以运行php extension/ocembed/bin/php/clear_cache_data.php -s<siteaccess>