1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-15 02:57:15 +02:00

Issue #4270 On-the-fly conversion to WebP format with fallback for older browsers when using toImage().

This commit is contained in:
Cameron
2020-12-09 10:54:15 -08:00
parent eb94769e1c
commit fb575c257c
5 changed files with 55 additions and 16 deletions

View File

@@ -986,6 +986,21 @@ while($row = $sql->fetch())
$result5 = $this->tp->toImage($src, ['type'=>'webp']);
$this->assertStringContainsString('&type=webp', $result5); // src
$this->tp->setConvertToWebP(true);
$result6 = $this->tp->toImage($src);
$tempDir = str_replace(['C:','\\'],['','/'],sys_get_temp_dir()).'/'; // FIXME
$expected = '<picture>
<source type="image/webp" srcset="'.$tempDir.'thumb.php?src=e_PLUGIN%2Fgallery%2Fimages%2Fbutterfly.jpg&amp;w=80&amp;h=80&amp;type=webp">
<source type="image/webp" srcset="'.$tempDir.'thumb.php?src=e_PLUGIN%2Fgallery%2Fimages%2Fbutterfly.jpg&amp;w=320&amp;h=320&amp;type=webp 4x">
<source type="image/jpeg" srcset="'.$tempDir.'thumb.php?src=e_PLUGIN%2Fgallery%2Fimages%2Fbutterfly.jpg&amp;w=320&amp;h=320 4x">
<img class="img-responsive img-fluid" src="'.$tempDir.'thumb.php?src=e_PLUGIN%2Fgallery%2Fimages%2Fbutterfly.jpg&amp;w=80&amp;h=80" alt="butterfly.jpg" width="80" height="80" />
</picture>';
$this->assertSame($expected,$result6);
$this->tp->setConvertToWebP(false);
}
public function testThumbSrcSet()