0.0.6 • Published 6 years ago

amp-react-square-img v0.0.6

Weekly downloads
9
License
MIT
Repository
github
Last release
6 years ago

Build Status codecov

amp-react-square-img:zap:

An amp-react component rendering image in square shape on AMP page. It will help you maintain the correct aspect ratio of image according to the resizing strategy(cover, contain ... etc) you specified.

Why need this?

background-size is the common solution we usually adopt to render a square image with correct aspect ratio. It means that you need to set the image source via background-image and inline style is required if image source is not static. Inline style will break an AMP page so we need to use another solution to achieve this.

Props

nametypedescription
srcstringthe url of image
srcsetstringsame as srcset attribute on the img tag
sizesstringsame as sizes attribute on the img tag
altstringsame as alt attribute on the img tag
attributionstringa string that indicates the attribution of the image
fallbackImgstringthe source url of fallback image
resizingStrategystringall the valid values of css property object-fit can be used here

Example

import SquareImage, { statics } from 'amp-react-square-img'
import 'amp-react-square-img/dist/css/component.css'

<SquareImage src='https://s.yimg.cc/irq/test.jpg' resizingStrategy={statics.CONTAIN_RESIZING} />

License

MIT

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago