You are here

public function MarkerIconService::getFileManagedUrl in Geofield Map 8.2

Generate File Managed Url from fid, and image style.

Parameters

int $fid: The file identifier.

string $image_style: The image style identifier.

Return value

string The url path to the file id (image style).

File

src/Services/MarkerIconService.php, line 605

Class

MarkerIconService
Provides an Icon Managed File Service.

Namespace

Drupal\geofield_map\Services

Code

public function getFileManagedUrl($fid = NULL, $image_style = 'none') {
  try {

    /* @var \Drupal\file\Entity\file $file */
    if (isset($fid) && ($file = $this->entityManager
      ->getStorage('file')
      ->load($fid))) {
      $uri = $file
        ->getFileUri();
      if ($this->moduleHandler
        ->moduleExists('image') && $image_style != 'none' && ImageStyle::load($image_style) && !$this
        ->fileIsManageableSvg($file)) {
        $url = ImageStyle::load($image_style)
          ->buildUrl($uri);
      }
      else {
        $url = file_create_url($uri);
      }
      return $url;
    }
  } catch (\Exception $e) {
    watchdog_exception('geofield_map', $e);
  }
  return NULL;
}