Exemplo n.º 1
0
 /**
  * Thumbnail URL getter
  *
  * @param  string $filePath original file path
  * @param  bool $checkFile OPTIONAL is it necessary to check file availability
  * @return string|false
  */
 public function getThumbnailUrl($filePath, $checkFile = false)
 {
     $mediaRootDir = $this->_cmsWysiwygImages->getStorageRoot();
     if (strpos($filePath, $mediaRootDir) === 0) {
         $thumbSuffix = self::THUMBS_DIRECTORY_NAME . substr($filePath, strlen($mediaRootDir));
         if (!$checkFile || $this->_directory->isExist($this->_directory->getRelativePath($mediaRootDir . '/' . $thumbSuffix))) {
             $thumbSuffix = substr($mediaRootDir, strlen($this->_directory->getAbsolutePath())) . '/' . $thumbSuffix;
             $randomIndex = '?rand=' . time();
             return str_replace('\\', '/', $this->_cmsWysiwygImages->getBaseUrl() . $thumbSuffix) . $randomIndex;
         }
     }
     return false;
 }
Exemplo n.º 2
0
 public function testGetBaseUrl()
 {
     $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($this->storeMock);
     $this->storeMock->expects($this->once())->method('getBaseUrl')->with(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
     $this->imagesHelper->getBaseUrl();
 }