function _image_source_image_exists

Checks whether the provided source image exists.

When a valid token is provided for the image URI, this function is equivalent to calling file_exists($image_uri).

Parameters

string $image_uri: The URI for the source image.

bool $token_is_valid: Whether a valid image token was supplied.

Return value

bool Whether the source image exists.

1 call to _image_source_image_exists()
image_style_deliver in modules/image/image.module
Page callback: Generates a derivative, given a style and image path.

File

modules/image/image.module, line 942

Code

function _image_source_image_exists($image_uri, $token_is_valid) {
    $exists = file_exists($image_uri);
    // If the file doesn't exist, we can stop here.
    if (!$exists) {
        return FALSE;
    }
    if ($token_is_valid) {
        return TRUE;
    }
    if (file_uri_scheme($image_uri) !== 'public') {
        return TRUE;
    }
    $image_path = drupal_realpath($image_uri);
    $private_path = variable_get('file_private_path', FALSE);
    if ($private_path) {
        $private_path = realpath($private_path);
        if ($private_path && strpos($image_path, $private_path) === 0) {
            return FALSE;
        }
    }
    return TRUE;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.