You are here

public function BackgroundImageManager::colorSampleFile in Background Image 2.0.x

Same name and namespace in other branches
  1. 8 src/BackgroundImageManager.php \Drupal\background_image\BackgroundImageManager::colorSampleFile()
  2. 2.x src/BackgroundImageManager.php \Drupal\background_image\BackgroundImageManager::colorSampleFile()

Samples the average color of an image file.

Parameters

\Drupal\file\FileInterface $file: A File entity object.

string $default: The default lowercase simple color (HEX) representation to use if unable to sample the image.

Return value

string The lowercase simple color (HEX) representation of the sampled image.

Overrides BackgroundImageManagerInterface::colorSampleFile

File

src/BackgroundImageManager.php, line 240

Class

BackgroundImageManager

Namespace

Drupal\background_image

Code

public function colorSampleFile(FileInterface $file = NULL, $default = NULL) {
  return isset($file) ? $this
    ->colorSampleImage($this->imageFactory
    ->get($file
    ->getFileUri()), $default) : $default;
}