You are here

public function BackgroundImage::getImageHash in Background Image 2.0.x

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

Retrieves the image based hash.

Return value

string

Overrides BackgroundImageInterface::getImageHash

1 call to BackgroundImage::getImageHash()
BackgroundImage::getCssClass in src/Entity/BackgroundImage.php

File

src/Entity/BackgroundImage.php, line 337

Class

BackgroundImage
Defines the Background Image entity.

Namespace

Drupal\background_image\Entity

Code

public function getImageHash() {
  if (!isset($this->imageHash)) {
    $image = $this
      ->getImageFile();
    $data = [
      'preload.background_color' => $this
        ->getSetting('preload.background_color'),
      'file' => $image ? $image
        ->getFileUri() : '',
    ];
    $this->imageHash = Crypt::hashBase64(serialize($data));
  }
  return $this->imageHash;
}