1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-30 09:39:55 +02:00

Issue #4270 Added .webp browser-support detection. Media-Manager "Convert to webp during render" can now be safely enabled and will temporarily fallback to the regular image if the browser does not support webp images.

This commit is contained in:
Cameron
2021-06-18 08:43:53 -07:00
parent a89b58a8a2
commit 7302803a75
3 changed files with 19 additions and 8 deletions

View File

@@ -1192,6 +1192,11 @@ while($row = $sql->fetch())
'options' => array('w'=>300, 'h'=>200, 'scale'=>'2x'),
'expected' =>'/thumb.php?src=e_PLUGIN%2Fgallery%2Fimages%2Fbutterfly.jpg&w=600&h=400'
),
4 => array(
'path' => '{e_PLUGIN}gallery/images/horse.jpg',
'options' => array('w'=>300, 'h'=>200, 'scale'=>'2x', 'type'=>'webp'),
'expected' =>'/thumb.php?src=e_PLUGIN%2Fgallery%2Fimages%2Fhorse.jpg&w=600&h=400&type=webp'
),
);
@@ -2298,14 +2303,15 @@ while($row = $sql->fetch())
$this->tp->setConvertToWebP(true);
$result6 = $this->tp->toImage($src);
$expected = '<img class="img-responsive img-fluid" src="thumb.php?src=e_PLUGIN%2Fgallery%2Fimages%2Fbutterfly.jpg&amp;w=80&amp;h=80&amp;type=webp" alt="butterfly.jpg" srcset="thumb.php?src=e_PLUGIN%2Fgallery%2Fimages%2Fbutterfly.jpg&amp;w=320&amp;h=320&amp;type=webp 4x" width="80" height="80" />';
/*
$expected = '<picture class="img-responsive img-fluid">
<source type="image/webp" srcset="thumb.php?src=e_PLUGIN%2Fgallery%2Fimages%2Fbutterfly.jpg&amp;w=320&amp;h=320&amp;type=webp 4x">
<source type="image/jpeg" srcset="thumb.php?src=e_PLUGIN%2Fgallery%2Fimages%2Fbutterfly.jpg&amp;w=320&amp;h=320 4x">
<source type="image/webp" srcset="thumb.php?src=e_PLUGIN%2Fgallery%2Fimages%2Fbutterfly.jpg&amp;w=80&amp;h=80&amp;type=webp">
<img class="img-responsive img-fluid" src="thumb.php?src=e_PLUGIN%2Fgallery%2Fimages%2Fbutterfly.jpg&amp;w=80&amp;h=80" alt="butterfly.jpg" width="80" height="80" />
</picture>';
</picture>';*/
// $tempDir = str_replace(['C:','\\'],['','/'], sys_get_temp_dir()).'/'; // FIXME
$result6 = preg_replace('/"([^"]*)thumb.php/','"thumb.php', $result6);