Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/shinshin86/img2amp-img

img to amp-img
https://github.com/shinshin86/img2amp-img

amp amp-img img img-to-amp-img img2amp-img

Last synced: 14 days ago
JSON representation

img to amp-img

Awesome Lists containing this project

README

        

![img2amp-img - logo](https://user-images.githubusercontent.com/8216064/111606270-63cf7680-881a-11eb-9ade-63670e7ea851.png)

# img2amp-img

[![Test](https://github.com/shinshin86/img2amp-img/actions/workflows/test.yml/badge.svg)](https://github.com/shinshin86/img2amp-img/actions/workflows/test.yml)

img to amp-img

```html
sample image
```

```html

```

## Install

```sh
npm install img2amp-img
# or
yarn add img2amp-img
```

## Usage

```javascript
const img2AmpImg = require('img2amp-img');

(async () => {
const imageTag = 'alt text';
const ampImgTag = await img2AmpImg(imageTag);
console.log(ampImgTag);
})();
```

Output

```html
Width of specified image
height="100" // -> Height of specified image
layout="responsive" // -> Now it's fixed at responsive
>
```

## Option

Can use the options corresponding to the layout attribute.

If no option is specified, `responsive` will be selected.

```
'responsive'
'fill'
'fixed'
'fixed-height'
'flex-item'
'intrinsic'
'nodisplay'
```

For more information about the option, please refer to the official AMP website.

[\ - amp.dev](https://amp.dev/documentation/components/amp-img/)

## Licence

[MIT](https://github.com/shinshin86/img2amp-img/blob/main/LICENSE)

## Author

[Yuki Shindo](https://shinshin86.com/en)