File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ public function PreviewLink($action = null)
110110
111111 // Temporarily disallow animated manipulations if necessary
112112 $ backend = $ this ->getImageBackend ();
113- $ origAllowAnimation = $ backend ->getAllowsAnimationInManipulations ();
113+ $ origAllowAnimation = $ backend? ->getAllowsAnimationInManipulations();
114114 if ($ origAllowAnimation && !static ::config ()->get ('allow_animated_preview ' )) {
115115 $ backend ->setAllowsAnimationInManipulations (false );
116116 }
Original file line number Diff line number Diff line change @@ -1273,4 +1273,34 @@ public function testMoveFileRenamesDuplicateFilename()
12731273 $ this ->assertTrue (strpos ($ file1 ->getFilename (), 'FileTest-v2.pdf ' ) !== false );
12741274 $ this ->assertTrue (strpos ($ file2 ->getFilename (), 'FileTest.pdf ' ) !== false );
12751275 }
1276+
1277+ public static function providePreviewLink (): array
1278+ {
1279+ return [
1280+ [true ],
1281+ [false ],
1282+ ];
1283+ }
1284+
1285+ #[DataProvider('providePreviewLink ' )]
1286+ public function testPreviewLink (bool $ fileExists ): void
1287+ {
1288+ $ image = Image::create ([
1289+ 'Name ' => 'animated.gif ' ,
1290+ 'FileFilename ' => 'animated.gif ' ,
1291+ ]);
1292+ $ image ->write ();
1293+ if ($ fileExists ) {
1294+ $ sourcePath = __DIR__ . '/ImageTest/ ' . $ image ->Name ;
1295+ $ image ->setFromLocalFile ($ sourcePath , $ image ->Filename );
1296+ }
1297+ $ image ->publishSingle ();
1298+
1299+ $ previewLink = $ image ->PreviewLink ();
1300+ if ($ fileExists ) {
1301+ $ this ->assertStringEndsWith ('/assets/FileTest/animated__FitMaxWzkzMCwzMzZd.gif ' , $ previewLink );
1302+ } else {
1303+ $ this ->assertStringContainsString ('/_resources/vendor/silverstripe/framework/client/images/app_icons/generic_92.png ' , $ previewLink );
1304+ }
1305+ }
12761306}
You can’t perform that action at this time.
0 commit comments