getResizedPath() public method

Get the path of the resized image
public getResizedPath ( ) : string
return string The path of the resized image
Esempio n. 1
0
 /**
  * Tests the getImage hook.
  */
 public function testExecuteResizeHook()
 {
     $GLOBALS['TL_HOOKS']['getImage'][] = [get_class($this), 'getImageHookCallback'];
     $file = new \File('dummy.jpg');
     $imageObj = new Image($file);
     $imageObj->setTargetWidth(100)->setTargetHeight(100);
     $imageObj->executeResize();
     $this->assertSame($imageObj->getResizedPath(), 'dummy.jpg%3B100%3B100%3Bcrop%3BContao%5CFile%3B%3BContao%5CImage');
 }
Esempio n. 2
0
 /**
  * Tests the getImage hook.
  */
 public function testGetImageHook()
 {
     $file = new \File('dummy.jpg');
     // Build cache before adding the hook
     $imageObj = new Image($file);
     $imageObj->setTargetWidth(50)->setTargetHeight(50);
     $imageObj->executeResize();
     $GLOBALS['TL_HOOKS'] = ['getImage' => [[get_class($this), 'getImageHookCallback']]];
     $imageObj = new Image($file);
     $imageObj->setTargetWidth(100)->setTargetHeight(100);
     $imageObj->executeResize();
     $this->assertSame('assets/dummy.jpg%26getImage_100_100_crop_Contao-File__Contao-Image.jpg', $imageObj->getResizedPath());
     $imageObj = new Image($file);
     $imageObj->setTargetWidth(50)->setTargetHeight(50);
     $imageObj->executeResize();
     $this->assertRegExp('(^assets/images/.*dummy.*.jpg$)', $imageObj->getResizedPath(), 'Hook should not get called for cached images');
     $imageObj = new Image($file);
     $imageObj->setTargetWidth($file->width)->setTargetHeight($file->height);
     $imageObj->executeResize();
     $this->assertSame('dummy.jpg', $imageObj->getResizedPath(), 'Hook should not get called if no resize is necessary');
     unset($GLOBALS['TL_HOOKS']);
 }