/
Asset.php
44 lines (39 loc) · 970 Bytes
/
Asset.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace Statamic\Tags;
use Statamic\Facades\Asset as AssetAPI;
use Statamic\Support\Arr;
class Asset extends Assets
{
/**
* Gets a single Asset's data from a value.
*
* Usage:
* {{ asset:[variable] }}
* {{ url }}, etc
* {{ /asset:[variable] }}
*
* Note:
* If the variable contains an array of IDs, we'll use only the first.
* To iterate over multiple assets, use {{ assets:[variable }} instead.
*
* @param $method
* @param $arguments
* @return string
*/
public function __call($method, $arguments)
{
$value = Arr::get($this->context, $this->method);
$value = (array) $value;
$value = current($value);
return $this->assets($value);
}
/**
* Gets a single Asset's data from a URL.
*
* @return mixed
*/
public function index()
{
return AssetAPI::find($this->params->get(['url', 'src']));
}
}