当前位置: 首页>>代码示例>>PHP>>正文


PHP MediaHelper::embed方法代码示例

本文整理汇总了PHP中MediaHelper::embed方法的典型用法代码示例。如果您正苦于以下问题:PHP MediaHelper::embed方法的具体用法?PHP MediaHelper::embed怎么用?PHP MediaHelper::embed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MediaHelper的用法示例。


在下文中一共展示了MediaHelper::embed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testEmbed

 public function testEmbed()
 {
     $result = $this->Media->embed('http://example.com/img/image-png');
     $this->assertFalse($result);
     $result = $this->Media->embed('img/image-png', array('url' => 'http://example.com'));
     $expected = '<a href="http://example.com"><img src="/media/static/img/image-png.png"  height="54" width="70"/></a>';
     $this->assertEqual($result, $expected);
     $result = $this->Media->embed('img/image-png', array('checked' => true, 'disabled' => true, 'noresize' => true, 'required' => true));
     $expected = '<img src="/media/static/img/image-png.png"  checked="checked" disabled="disabled" noresize="noresize" required="required" height="54" width="70"/>';
     $this->assertEqual($result, $expected);
     $this->Data->getFile(array('audio-mp3.mp3' => $this->Data->settings['special'] . 'img/special-audio-&-mp3.mp3'));
     $result = $this->Media->embed('img/special-audio-&-mp3');
     $expected = '<audio controls="controls"><source src="http://fo&amp;o:bar@example.com/media/special%5Bfolder%5D/img/special-audio-%26-mp3.mp3" type="audio/mpeg"/></audio>';
     $this->assertEqual($result, $expected);
     $result = $this->Media->embed('img/special-image-&-png');
     $expected = '<img src="http://fo&amp;o:bar@example.com/media/special%5Bfolder%5D/img/special-image-%26-png.png"  height="54" width="70"/>';
     $this->assertEqual($result, $expected);
     $this->Data->getFile(array('video-wmv.wmv' => $this->Data->settings['special'] . 'img/special-video-&-wmv.wmv'));
     $result = $this->Media->embed('img/special-video-&-wmv');
     $expected = '<video controls="controls"><source src="http://fo&amp;o:bar@example.com/media/special%5Bfolder%5D/img/special-video-%26-wmv.wmv" type="video/x-ms-wmv"/></video>';
     $this->assertEqual($result, $expected);
     $result = $this->Media->embed('img/image-png', array('id' => 'my-image', 'class' => 'image', 'data-custom' => 42));
     $expected = '<img src="/media/static/img/image-png.png"  id="my-image" class="image" data-custom="42" height="54" width="70"/>';
     $this->assertEqual($result, $expected);
     $this->Data->getFile(array('audio-mp3.mp3' => $this->Data->settings['static'] . 'aud/audio-mp3.mp3'));
     $result = $this->Media->embed('aud/audio-mp3');
     $expected = '<audio controls="controls"><source src="/media/static/aud/audio-mp3.mp3" type="audio/mpeg"/></audio>';
     $this->assertEqual($result, $expected);
     $result = $this->Media->embed('img/image-png');
     $expected = '<img src="/media/static/img/image-png.png"  height="54" width="70"/>';
     $this->assertEqual($result, $expected);
     $this->Data->getFile(array('video-wmv.wmv' => $this->Data->settings['static'] . 'vid/video-wmv.wmv'));
     $result = $this->Media->embed('vid/video-wmv');
     $expected = '<video controls="controls"><source src="/media/static/vid/video-wmv.wmv" type="video/x-ms-wmv"/></video>';
     $this->assertEqual($result, $expected);
     $result = $this->Media->embed('vid/video-wmv', array('poster' => $this->file0));
     $expected = '<video height="54" width="70" controls="controls" poster="/media/static/img/image-png.png"><source src="/media/static/vid/video-wmv.wmv" type="video/x-ms-wmv"/></video>';
     $this->assertEqual($result, $expected);
     $result = $this->Media->embed('non-existent');
     $expected = '';
     $this->assertEqual($result, $expected);
 }
开发者ID:miznokruge,项目名称:base-cake,代码行数:42,代码来源:MediaHelperTest.php


注:本文中的MediaHelper::embed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。