1.3.1 • Published 9 years ago

gulp-imgsizefix v1.3.1

Weekly downloads
3
License
ISC
Repository
github
Last release
9 years ago

gulp-imgsizefix

fix an IMG tags width and height attributes.

Usage

var
  gulp = require("gulp"),
  imgsizefix = require("gulp-imgsizefix");

gulp.task("default", function () {
  gulp.src("./www/index.html")
    .pipe(imgsizefix({
      paths: {
        "www/": [
          new RegExp("^\\/"),
          "http://example.com"
        ]
      }
    }))
    .pipe(gulp.dest('./www'));
});

Task Results

Input

<!-- absolute path -->
<img src="/img/128x64.gif" width>
<img src="/img/128x64.gif" height>
<img src="/img/128x64.gif" width height>
<!-- remote path -->
<img src="http://example.com/img/128x64.gif" width>
<img src="http://example.com/img/128x64.gif" height>
<img src="http://example.com/img/128x64.gif" width height>
<!-- relative path -->
<img src="./img/128x64.gif" width>
<img src="./img/128x64.gif" height>
<img src="./img/128x64.gif" width height>

Output

<!-- absolute path -->
<img src="/img/128x64.gif" width="128">
<img src="/img/128x64.gif" height="64">
<img src="/img/128x64.gif" width="128" height="64">
<!-- remote path -->
<img src="http://example.com/img/128x64.gif" width="128">
<img src="http://example.com/img/128x64.gif" height="64">
<img src="http://example.com/img/128x64.gif" width="128" height="64">
<!-- relative path -->
<img src="./img/128x64.gif" width="128">
<img src="./img/128x64.gif" height="64">
<img src="./img/128x64.gif" width="128" height="64">

Force Option

var
  gulp = require("gulp"),
  imgsizefix = require("gulp-imgsizefix");

gulp.task("default", function () {
  gulp.src("./www/index.html")
    .pipe(imgsizefix({
      paths: {
        "www/": [
          new RegExp("^\\/"),
          "http://example.com"
        ]
      },
      force: true // <-- default: false
    }))
    .pipe(gulp.dest('./www'));
});

Task Results

Input

<!-- absolute path -->
<img src="/img/128x64.gif">
<img src="/img/128x64.gif">
<img src="/img/128x64.gif">
<!-- remote path -->
<img src="http://example.com/img/128x64.gif">
<img src="http://example.com/img/128x64.gif">
<img src="http://example.com/img/128x64.gif">
<!-- relative path -->
<img src="./img/128x64.gif">
<img src="./img/128x64.gif">
<img src="./img/128x64.gif">

Output

<!-- absolute path -->
<img src="/img/128x64.gif" width="128" height="64">
<img src="/img/128x64.gif" width="128" height="64">
<img src="/img/128x64.gif" width="128" height="64">
<!-- remote path -->
<img src="http://example.com/img/128x64.gif" width="128" height="64">
<img src="http://example.com/img/128x64.gif" width="128" height="64">
<img src="http://example.com/img/128x64.gif" width="128" height="64">
<!-- relative path -->
<img src="./img/128x64.gif" width="128" height="64">
<img src="./img/128x64.gif" width="128" height="64">
<img src="./img/128x64.gif" width="128" height="64">
1.3.1

9 years ago

1.3.0

9 years ago

1.2.2

10 years ago

1.2.1

10 years ago

1.2.0

10 years ago

1.1.0

10 years ago

1.0.0

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago