1.2.0 • Published 7 years ago

@pluritech/ng-image-preview v1.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

Angular Image Preview

This library was creating to abstract the LQIP – Low Quality Image Placeholders technique used by Medium and Instagram to Angular apps. The code was implemented inspired by this awesome codepen made by @JMPerez.

And we used RandomUser API to make our tests in development environment.

How it works? (short explanation)

First, we load the image with low quality and it is really fast. So, the user who have a slow internet can see a preview of what is coming. Then, we load the same image, but, with a high quality.

It is a short explanation of how this technique works, if you want to know more, just visit the links above!

Installation

To install this library, run:

$ npm install @pluritech/ng-image-preview --save

Using the ng-image-preview

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';

// Import the library
import { NgImagePreviewModule } from '@pluritech/ng-image-preview';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,

    // Specify the library as an import
    NgImagePreviewModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Once the library is imported, you can use image-preview component in your Angular application:

<div *ngFor="let picture of pictures">
  <image-preview
   [lowImage]="picture.thumbnail"
   [hqImage]="picture.large"
   paddingBottom="95%"
   fallbackSrc="./assets/no-image-box.png"
   filterLowImage="blur(10px)">
  </image-preview>
</div>

Parameters

ParameterDescription
lowImagelow image url
hqImagehigh quality image url
paddingBottoma padding-bottom value, to prevent the reflow, default is 66.6%
fallbackSrca path to fallback image the will replace the hqImage if occur an error on load
bgPlaceholdera background-color value to fill the placeholder 'container'
filterLowImagea filter value to image small like 'blur(10px)'. Default is 'blur(20px)'
alta value 'alt' to both, low image and high image
titlea value 'title' to both, low image and high image

To do

  • Manage images in cache

Feel free to make your pull request.

Fix Issues

  • 1.1.1 - Now you can use the operator Elvis to load data async, without the needed of use the *ngIf

Authors

License

MIT © Lucas Correa & Mateus Durães & Luis Moreno

1.2.0

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.1.0

7 years ago