nexuslinkservices / assets-finder
v1.0.0
2016-09-06 13:27 UTC
Requires
- php: >=5.6.2
Requires (Dev)
- phpunit/phpunit: 5.5.*
- symfony/yaml: ~2.3|~3.0
This package is not auto-updated.
Last update: 2024-09-20 22:06:46 UTC
README
扩展,用于获取媒体资产数组,如MP3、MP4和JPG。
安装
如果您使用composer,可以通过以下命令添加此包:
composer require galiteintechnologies/assets-finder
用法
在配置yml文件中定义和设置媒体参数的值,例如:
media_options:
mp3: true
mp4: true
jpg: true
您可以使用true/false值启用或禁用解析媒体选项。
如果您在配置文件中未设置媒体选项,则默认情况下所有选项都将取true值。
示例用法
<?php
use AssetsFinder\MediaParser;
$assetsFinder = new MediaParser;
$content = "First sample file http://www.mywebsite.com/firstsample.mp3 and second file is https://www.mywebsite.com/secondsample.mp4. This is the image link <img src='http://www.mywebsite.com/assets/images/sampleimage.jpg' alt='sample image' title='sample image'> and second image <img src='http://www.mywebsite.com/assets/images/sampleimage2.png' alt='test png image' title='test png image'>";
$result = $assetsFinder->FindMedia($content);
输出
Array
(
[mp3] => Array
(
[0] => http://www.mywebsite.com/firstsample.mp3
)
[mp4] => Array
(
[0] => https://www.mywebsite.com/secondsample.mp4
)
[jpg] => Array
(
[0] => http://www.mywebsite.com/assets/images/sampleimage.jpg
)
)
贡献
欢迎提交pull请求。