Skip to content
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

IBX-4647: Added WebpFormatVariationPathGenerator handling .webp images #361

Conversation

webhdx
Copy link
Contributor

@webhdx webhdx commented Feb 9, 2023

Question Answer
JIRA issue IBX-4647
Type bug
Target Ibexa version v3.3
BC breaks no

liip/imagine package has support for generating .webp images. You can explicitly define format: webp for image variation and it'll encode the image + serve it with .webp extension. This isn't supported on our side. Even if you use format: webp configuration, the image is encoded properly but it's still returned with original file extension. This PR adds new VariationPathGenerator that checks for webp format and applies .webp file extension.

Checklist:

  • Provided PR description.
  • Tested the solution manually.
  • Provided automated test coverage.
  • Checked that target branch is set correctly (master for features, the oldest supported for bugs).
  • Ran PHP CS Fixer for new PHP code (use $ composer fix-cs).
  • Asked for a review (ping @ezsystems/engineering-team).

@webhdx webhdx self-assigned this Feb 9, 2023
@webhdx webhdx added Bug Something isn't working Ready for review labels Feb 9, 2023
return $variationPath;
}

return $variationPath . '.webp';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't this result with e.g. image.jpg.webp instead of image.webp

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct. It looks weird but webp format actually uses double extension: https://symfony.com/bundles/LiipImagineBundle/current/basic-usage.html#use-webp-if-supported

eZ/Bundle/EzPublishCoreBundle/Resources/config/image.yml Outdated Show resolved Hide resolved
);

self::assertEquals(
'tmp/variation/test.jpeg.webp',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really correct? Not test.webp?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. WebP format can work with JPEGs, GIFs and PNGs.

@webhdx
Copy link
Contributor Author

webhdx commented Feb 9, 2023

Fixed all remarks: 7e76a66 I moved WebpFormatVariationPathGenerator to Ibexa\Core\Imagine\VariationPathGenerator namespace.

@webhdx webhdx requested review from alongosz and a team February 9, 2023 14:49
@webhdx webhdx force-pushed the IBX-4647_ibexa_image_alias_does_not_respect_webp_with_liip_imagine branch from e201da1 to d53b18f Compare February 10, 2023 10:38
@sonarcloud
Copy link

sonarcloud bot commented Feb 10, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@bogusez bogusez self-assigned this Feb 13, 2023
@bogusez bogusez added QA approved Ready for MERGE To be set by author or maintainer labels Feb 15, 2023
@adamwojs adamwojs merged commit 0d4e86d into 1.3 Feb 15, 2023
@adamwojs adamwojs deleted the IBX-4647_ibexa_image_alias_does_not_respect_webp_with_liip_imagine branch February 15, 2023 11:51
@adamwojs
Copy link
Member

Could you please merge up changes @webhdx ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working QA approved Ready for MERGE To be set by author or maintainer Ready for review
9 participants