我正在获取这样的云图像/视频ID:
print "Why does this bare call to foo not run?\n";
foo;
print "When this call to foo() does run?\n";
foo();
print "And this call to &foo also runs?\n";
&foo;
sub foo {
print " print from inside function foo:\n";
}
print "And this bare call to foo below the function definition, does run?\n";
foo;
,它提供如下网址: http://res.cloudinary.com/dviiu412p/image/upload/v1/campaigns/1/jfle7ilxkyfmj9mjggwa
然后将其渲染为图像或视频,如下所示:
<?php echo cloudinary_url($_upload->getPublicId()); ?>
问题是我只想提供图片或视频(无论用户上传哪一个)。有没有办法实现这个目标?我认为instanceof也许可以做到这一点,但我以前从未使用过它。任何帮助将不胜感激
答案 0 :(得分:0)
假设$_upload
的来源是上传响应,那么您也拥有resource_type
值。您需要resource_type
的值与公共ID相结合,以区分资源(图像,视频或原始)。然后,您可以使用switch-case块生成正确的标记。
例如,
<!-- language: lang-php -->
switch ($result["resource_type"]) {
case "image":
// generate image tag
break;
case "video":
// generate video tag
break;
}