You are here

public static function TwigTweakExtension::fileUrlFilter in Twig Tweak 3.x

Same name and namespace in other branches
  1. 3.1.x src/TwigTweakExtension.php \Drupal\twig_tweak\TwigTweakExtension::fileUrlFilter()

Returns a URL path to the file.

Parameters

string|object $input: Can be either file URI or an object that contains the URI.

bool $relative: (optional) Whether the URL should be root-relative, defaults to true.

Return value

string|null A URL that may be used to access the file.

File

src/TwigTweakExtension.php, line 623

Class

TwigTweakExtension
Twig extension with some useful functions and filters.

Namespace

Drupal\twig_tweak

Code

public static function fileUrlFilter($input, bool $relative = TRUE) : ?string {
  return \Drupal::service('twig_tweak.url_extractor')
    ->extractUrl($input, $relative);
}