-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing descriptor in webp source srcset #43
Comments
Hello @Manours, looks like a bug the Can you create a failing test case for it? You can copy exist test case like the following and adjust it: web-twig/tests/Unit/ImageExtensionTest.php Lines 114 to 138 in fad2eb0
|
I've created that test : public function testComplexWebpPictureTag(): void
{
$imageExtension = new ImageExtension('/lazy');
$imageExtension = new ImageExtension(null, [], ['webp' => 'image/webp']);
$this->assertSame(
'<picture>' .
'<source srcset="/uploads/media/sulu-100x100/01/image.webp?v=1-0 460w, /uploads/media/sulu-170x170/01/image.webp?v=1-0 800w, /uploads/media/sulu-400x400/01/image.webp?v=1-0 1024w"' .
' type="image/webp">' .
'<img alt="Logo"' .
' title="Description"' .
' src="/uploads/media/sulu-400x400/01/image.jpg?v=1-0"' .
' srcset="/uploads/media/sulu-100x100/01/image.jpg?v=1-0 460w, /uploads/media/sulu-170x170/01/image.jpg?v=1-0 800w, /uploads/media/sulu-400x400/01/image.jpg?v=1-0 1024w"' .
' sizes="(max-width: 1024px) 100vw, (max-width: 800px) 100vw, 100vw"' .
' id="image-id"' .
' class="image-class">' .
'</picture>',
$imageExtension->getImage(
$this->image,
[
'src' => 'sulu-400x400',
'srcset' => 'sulu-100x100 460w, sulu-170x170 800w, sulu-400x400 1024w',
'sizes' => '(max-width: 1024px) 100vw, (max-width: 800px) 100vw, 100vw',
'id' => 'image-id',
'class' => 'image-class',
'alt' => 'Logo',
]
)
);
} And this is the result : 1) Sulu\Twig\Extensions\Tests\Unit\ImageExtensionTest::testComplexWebpPictureTag
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'<picture><source srcset="/uploads/media/sulu-100x100/01/image.webp?v=1-0 460w, /uploads/media/sulu-170x170/01/image.webp?v=1-0 800w, /uploads/media/sulu-400x400/01/image.webp?v=1-0 1024w" type="image/webp"><img alt="Logo" title="Description" src="/uploads/media/sulu-400x400/01/image.jpg?v=1-0" srcset="/uploads/media/sulu-100x100/01/image.jpg?v=1-0 460w, /uploads/media/sulu-170x170/01/image.jpg?v=1-0 800w, /uploads/media/sulu-400x400/01/image.jpg?v=1-0 1024w" sizes="(max-width: 1024px) 100vw, (max-width: 800px) 100vw, 100vw" id="image-id" class="image-class"></picture>'
+'<picture><source srcset="/uploads/media/sulu-400x400/01/image.webp?v=1-0, /uploads/media/sulu-100x100/01/image.webp?v=1-0 460w, /uploads/media/sulu-170x170/01/image.webp?v=1-0 800w, /uploads/media/sulu-400x400/01/image.webp?v=1-0 1024w" type="image/webp"><img alt="Logo" title="Description" src="/uploads/media/sulu-400x400/01/image.jpg?v=1-0" srcset="/uploads/media/sulu-100x100/01/image.jpg?v=1-0 460w, /uploads/media/sulu-170x170/01/image.jpg?v=1-0 800w, /uploads/media/sulu-400x400/01/image.jpg?v=1-0 1024w" sizes="(max-width: 1024px) 100vw, (max-width: 800px) 100vw, 100vw" id="image-id" class="image-class"></picture>' |
@Manours can you create a pull request with it? Would be great. |
From issue sulu#43
Thank you, fixed in 2.5.4. |
Thank you 👍 |
I'm back @alexander-schranz … 👋 I just remember that the Could you please handle this ? |
@Manours Yeah definitly a bug when the validators says that. Can you create a test case with the |
Is this okay @alexander-schranz ? |
Thx for the reproducer. PR is merged will fix another issue and great a release soon |
Hi there 👋
I just found a curious behaviour when I use the
get_image
function with thewebp
format enabled.This line :
Generate this HTML :
If you look at the
srcset
in the webpsource
, the first url doesn't have a descriptor (like1000w
) which causes strange behavior by the browser.I guess this url matches the
src
argument but I can't do whitout it.Is there a way to remove it ?
The text was updated successfully, but these errors were encountered: