Skip to content

Image component alignment and placeholder - #10315

Merged
jroebu14 merged 4 commits into
latestfrom
image-component-fixes
Sep 26, 2022
Merged

Image component alignment and placeholder#10315
jroebu14 merged 4 commits into
latestfrom
image-component-fixes

Conversation

@jroebu14

@jroebu14 jroebu14 commented Sep 23, 2022

Copy link
Copy Markdown

Supports #10306

Overall change:
While replacing the old image component with the new one in the StoryPromo component, some minor behaviour differences were observed. These include:

  • when aspect ratio defined is different from image's intrinsic aspect ratio, image was not centred in container
  • PNG transparent images revealed the container's placeholder
  • sizes attribute with default 100vw was sizing the image in AMP incorrectly when dimensions were not provided
  • attribution prop for AMP images did not exist

This PR addresses the above issues and updates the README to explain better how the aspect ratio works.

Code changes:

  • uses state and onLoad event to trigger removing placeholder when image has loaded so transparent PNG images do not reveal placeholder
  • fixes aspect ratio centering using aspectRatio and objectFit:cover CSS properties
  • fixes AMP image scaling incorrectly when dimensions are not provided using technique described here. also removes default 100vw sizes value as this contributed to incorrect scaling

  • I have assigned myself to this PR and the corresponding issues
  • I have added the cross-team label to this PR if it requires visibility across World Service teams
  • I have assigned this PR to the Simorgh project
  • (BBC contributors only) This PR follows the repository use guidelines

Testing:

  • Automated (jest and/or cypress) tests added (for new features) or updated (for existing features)
  • If necessary, I have run the local E2E non-smoke tests relevant to my changes (CYPRESS_APP_ENV=local CYPRESS_SMOKE=false yarn test:e2e:interactive)
  • This PR requires manual testing

@eagerterrier eagerterrier left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

T-Shirt-Image-2_1-1

@jroebu14
jroebu14 merged commit 2c60084 into latest Sep 26, 2022
@jroebu14
jroebu14 deleted the image-component-fixes branch September 26, 2022 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants