-
Notifications
You must be signed in to change notification settings - Fork 687
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add pjpg format only if image type of not png. #2400
Conversation
|
|
||
const imageFileType = getFileType(baseURL); | ||
if (imageFileType === 'png') { | ||
params.set('format', 'png'); // use png if webp is not available |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Piggybacking on the comment @Jordaneisenburger made on the issue, what should we do to make this extensible?
Should we do something like this?
if (isValidImageFileType(imageFileType)) {
params.set('format', imageFileType);
} else {
params.set('format', 'pjpg');
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating the tests as well. I think this is the fix we're looking for. At the moment, I'm not sure how to open up these build processes to customization, but we'll have to spike on it.
Performance Test Results The following fails have been reported by WebpageTest. These numbers indicates a possible performance issue with the PR which requires further manual testing to validate. https://pr-2400.pwa-venia.com/venia-tops.html : LH Performance Expected 0.75 Actual 0.66 |
Description
This PR adds logic in
makeUrl.js
file invenia-ui
to handle png image requests.Currently, the
makeOptimizedUrl
function does not consider the file type while adding URLSearchParams. It addswebp
andpjpg
in that respective order. This means if the server can not handlewebp
it will considerpjpg
.webp
is compatible withpng
, so when the user requests apng
it will be returned with a transparent background.If the server does not support
webp
since the current code does not regardpng
and appliespjpg
as the format, instead of a transparent background, we will get the image with a black background.But with the current change, instead of
pjpg
the UI will request apng
instead.All this happens only if the backend does not support
webp
and is served by a backend that does not handlepjpg
properly. For instance, we were not able to reproduce this issue till we switched off fastly, because fastly handlespjpg
well and does not return a black background. When we switched off fastly, the backend image optimization was handled by hastily which was retuning the black background.I am not sure if the approach taken by fastly or hastily is correct but one thing is for sure, we have to send format as
png
for apng
image request irrespective of the backend.Troubleshooting Tips:
webp
. If it does, everything should be fine.URLSearchParams
.Related Issue
Closes #2340
Verification Stakeholders
@zetlen
@jimbo
@Jordaneisenburger
Verification Steps
To test use this, use this backend URL:
MAGENTO_BACKEND_URL=https://staging-5em2ouy-mfwmkrjfqvbjk.us-4.magentosite.cloud/
Screenshots / Screen Captures (if appropriate)
Checklist
None