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

[bug]: The generateSrcset can generate broken images #2287

Closed
1 of 8 tasks
Jordaneisenburger opened this issue Mar 26, 2020 · 0 comments · Fixed by #2300
Closed
1 of 8 tasks

[bug]: The generateSrcset can generate broken images #2287

Jordaneisenburger opened this issue Mar 26, 2020 · 0 comments · Fixed by #2300
Assignees
Labels
bug Something isn't working help wanted Eligible for community contribution.

Comments

@Jordaneisenburger
Copy link
Member

Describe the bug
The util function generateSrcset has the possibility to generate broken images.

if we take a look at the function you can see at line 69 we are dividing a with by a ratio. This works in most cases but when this division doesn't end in a round number we have an issue.

export const generateSrcset = (imageURL, type) => {
if (!imageURL || !type) return '';
const generateSrcsetUrl = generateUrl(imageURL, type);
return Array.from(imageWidths, ([, value]) => value)
.map(
width =>
`${generateSrcsetUrl(
width,
width / DEFAULT_WIDTH_TO_HEIGHT_RATIO
)} ${width}w`
)
.join(',\n');
};

To reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
It should always give a round number

Screenshots
Screenshot 2020-03-26 at 21 55 44

Possible solutions
add Math.round() around line 69

Please complete the following device information:

  • Device [e.g. iPhone6, PC, Mac, Pixel3]:
  • OS [e.g. iOS8.1, Windows 10]:
  • Browser [e.g. Chrome, Safari]:
  • Browser Version [e.g. 22]:
  • Magento Version:
  • PWA Studio Version:
  • NPM version npm -v:
  • Node Version node -v:

Please let us know what packages this bug is in regards to:

  • venia-concept
  • venia-ui
  • pwa-buildpack
  • peregrine
  • pwa-devdocs
  • upward-js
  • upward-spec
  • create-pwa
@Jordaneisenburger Jordaneisenburger added bug Something isn't working help wanted Eligible for community contribution. labels Mar 26, 2020
@larsroettig larsroettig self-assigned this Mar 31, 2020
dpatil-magento added a commit that referenced this issue Apr 6, 2020
Co-authored-by: Devagouda <40405790+dpatil-magento@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Eligible for community contribution.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants