You are here

private function HtmlAssetInliner::remote_file_exists in TMGMT Translator Smartling 8

Same name and namespace in other branches
  1. 8.4 src/Context/HtmlAssetInliner.php \Drupal\tmgmt_smartling\Context\HtmlAssetInliner::remote_file_exists()
  2. 8.2 src/Context/HtmlAssetInliner.php \Drupal\tmgmt_smartling\Context\HtmlAssetInliner::remote_file_exists()
  3. 8.3 src/Context/HtmlAssetInliner.php \Drupal\tmgmt_smartling\Context\HtmlAssetInliner::remote_file_exists()

Checks whether or not remote file exists

Parameters

$url:

Return value

bool

1 call to HtmlAssetInliner::remote_file_exists()
HtmlAssetInliner::convertImageToDataUri in src/Context/HtmlAssetInliner.php
Converts images to data URIs

File

src/Context/HtmlAssetInliner.php, line 173

Class

HtmlAssetInliner

Namespace

Drupal\tmgmt_smartling\Context

Code

private function remote_file_exists($url) {
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);

  # don't download content
  curl_setopt($ch, CURLOPT_NOBODY, 1);
  curl_setopt($ch, CURLOPT_FAILONERROR, 1);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  if (curl_exec($ch) !== FALSE) {
    return TRUE;
  }
  return FALSE;
}