Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/ismamz/posthtml-alt-always

Always add alt attibute for images that don't have it (accessibility reasons)
https://github.com/ismamz/posthtml-alt-always

Last synced: 15 days ago
JSON representation

Always add alt attibute for images that don't have it (accessibility reasons)

Awesome Lists containing this project

README

        

# Alt Always

PostHTML Logo

[![NPM Version][npm-img]][npm] [![Build Status][ci-img]][ci]

[Alt Always](http://github.com/ismamz/posthtml-alt-always) is a [PostHTML] plugin that always add alt attribute for images that don't have it (accessibility reasons).

> **Every image must have an `alt` attribute.** This is a requirement of HTML standard (with perhaps a few exceptions in HTML5). Images without an alt attribute are likely inaccessible. In some cases, images may be given an empty or null `alt` attribute (e.g., `alt=""`).

Read more about [Alternative Text](http://webaim.org/techniques/alttext/).

```html



I already have alternative text



I already have alternative text
```

## Usage

Add **Alt Always** to your build tool:

```bash
npm install posthtml-alt-always --save-dev
```

#### Node

```js
require('posthtml-alt-always').process(YOUR_HTML, { /* options */ });
```

#### PostHTML

Add [PostHTML] to your build tool:

```bash
npm install posthtml --save-dev
```

Load Alt Always as a PostHTML plugin:

```js
posthtml([
require('posthtml-alt-always')({ /* options */ })
]).process(YOUR_HTML, /* options */);
```

#### Gulp

Add [Gulp PostHTML] to your build tool:

```bash
npm install gulp-posthtml --save-dev
```

Enable Alt Always within your Gulpfile:

```js
var posthtml = require('gulp-posthtml');

gulp.task('html', function () {
return gulp.src('./src/*.html').pipe(
posthtml([
require('posthtml-alt-always')({ /* options */ })
])
).pipe(
gulp.dest('.')
);
});
```

#### Grunt

Add [Grunt PostHTML] to your build tool:

```bash
npm install grunt-posthtml --save-dev
```

Enable [alt-always] within your Gruntfile:

```js
grunt.loadNpmTasks('grunt-posthtml');

grunt.initConfig({
posthtml: {
options: {
use: [
require('posthtml-alt-always')({ /* options */ })
]
},
dist: {
src: '*.html'
}
}
});
```

[ci]: https://travis-ci.org/ismamz/posthtml-alt-always
[ci-img]: https://img.shields.io/travis/ismamz/posthtml-alt-always.svg
[npm]: https://www.npmjs.com/package/posthtml-alt-always
[npm-img]: https://img.shields.io/npm/v/posthtml-alt-always.svg

[Gulp PostHTML]: https://github.com/posthtml/gulp-posthtml
[Grunt PostHTML]: https://github.com/TCotton/grunt-posthtml
[PostHTML]: https://github.com/posthtml/posthtml

[alt-always]: https://github.com/ismamz/posthtml-alt-always