private function getImagePath(FileStorage $entity, string $version) : string
    {
        $hash = (string)Configure::read(sprintf('FileStorage.imageHashes.file_storage.%s', $version));
        if (empty($hash)) {
            return $entity->get('path');
        }

        $event = new Event('ImageVersion.getVersions', $this, [
            'hash' => $hash,
            'image' => $entity,
            'version' => $version,
            'options' => [],
            'pathType' => 'fullPath'
        ]);

        EventManager::instance()->dispatch($event);

        if (! $event->getResult()) {
            return $entity->get('path');
        }

        return file_exists(WWW_ROOT . trim($event->getResult(), DS)) ?
            $event->getResult() :
            $entity->get('path');
    }