|media

|media

Twig Filter

The |media filter returns an address relative to the public path of the media manager library. The result is a URL to the media file specified in the filter parameter.

<img src="{{ 'banner.jpg'|media }}" />

If the media manager address is https://cdn.octobercms.com the above example would output the following:

<img src="https://cdn.octobercms.com/banner.jpg" />

# PHP Interface

You may generate URLs in PHP using the Media\Classes\MediaLibrary class and url method.

MediaLibrary::url('relative/path/to/asset.jpg');
On This Page