1 image.module _image_source_image_exists($image_uri)

Checks whether the provided source image exists.

Parameters

string $image_uri: The URI for the source image.

Return value

bool: Whether the source image exists.

File

core/modules/image/image.module, line 813
Exposes global functionality for creating image styles.

Code

function _image_source_image_exists($image_uri) {
  $exists = file_exists($image_uri);

  // If the file doesn't exist, we can stop here.
  if (!$exists) {
    return FALSE;
  }

  if (file_uri_scheme($image_uri) !== 'public') {
    return TRUE;
  }

  $image_path = backdrop_realpath($image_uri);
  $private_path = config_get('system.core', 'file_private_path');
  if ($private_path) {
    $private_path = realpath($private_path);
    if ($private_path && strpos($image_path, $private_path) === 0) {
      return FALSE;
    }
  }

  return TRUE;
}