npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ionic-attributed-image-loader

v4.2.14

Published

Ionic Component and Service to load attributed (style/class) images in a background thread and cache them for later use

Downloads

7

Readme

npm npm npm

Ionic Attributed Image Loader

Ionic Module that loads images in a native background thread and caches them for later use. Uses cordova-plugin-file and cordova-plugin-file-transfer via ionic-native wrappers.

#This is a forked module* This module has been forked from the original ionic-image-loader module by Zyra Media. Please refer to the original module page (https://github.com/zyramedia) for full documentation.

Features

  • Enhances the Zyra Media ionic-image-loader by providing the ability to pass through image attributes when generating the HTML tags.

Installation

1. Install the NPM Package

npm install --save ionic-image-loader

2. Install Required Plugins

npm i --save @ionic-native/file
ionic cordova plugin add cordova-plugin-file

npm i --save @ionic-native/file-transfer
ionic cordova plugin add cordova-plugin-file-transfer

3. Import IonicAttributedImageLoader module

Add IonicAttributedImageLoader.forRoot() in your app's root module

import { IonicAttributedImageLoader } from 'ionic-attributed-image-loader';

// import the module
@NgModule({
  ...
  imports: [
    IonicAttributedImageLoader.forRoot()
  ]
})
export class AppModule {}

Then add IonicAttributedImageLoader in your child/shared module(s)

import { IonicAttributedImageLoader } from 'ionic-attributed-image-loader';

@NgModule({
  ...
  imports: [
    IonicAttributedImageLoader
  ]
})
export class SharedModule {}

Usage

Basic Usage

By default, the module sets the image as the background of the <img-loader> element. If you want the module to use the image as an <img> tag inside the <img-loader> elemen, just add useImg attribute as shown below:

<img-loader src="https://path.to/my/image.jpg" useImg></img-loader>

You can also listen to the load event to be notified when the image has been loaded:

<img-loader src="path/to/image" (load)="onImageLoad($event)></img-loader>
import { ImgLoader } from 'ionic-image-loader';


## Advanced Usage
The `<img-loader>` component takes many attributes that allows you to customize the image. You can use the following table as a reference:

| Attribute Name | Type | Description | Default Value |
| --- | --- | --- | --- |
| src | string | The image URL | N/A |
| fallback | string | Fallback image url to load in case the original image fails to load | N/A |
| spinner | boolean | Show a spinner while the image loads | true |
| useImg | boolean | Use `<img>` tag to display the image in | false |
| width | string | The width of the image. This is ignored if `useImg` is set to `true`. | 100% |
| height | string | The height of the image. This is ignored if `useImg` is set to `true`. | 100% |
| display | string | Sets the `display` CSS property of the `<img-loader>` element. This is ignored if `useImg` is set to `true`. | block |
| backgroundSize | string | Sets the `background-size` CSS property of the `<img-loader>` element. This is ignored if `useImg` is set to `true`. | contain |
| backgroundRepeat | string | Sets the `background-repeat` CSS property of the `<img-loader>` element. This is ignored if `useImg` is set to `true`. | no-repeat |
| fallbackAsPlaceholder | boolean | Use fallback as a placeholder until the image loads. | false |
| imgAttributes | ImageAttribute[] | An array of ImageAttribute objects (element, value).  If `useImg == true`, this array will be iterated and each object added as an attribute to the generated `<img>` HTML element. | []] |


**Note:** The default values can be changed using the [global configuration](https://github.com/zyramedia/ionic-image-loader#global-configuration) feature.



# Passing HTML / CSS Attributes to a generated image

When using ImageLoader to generate an `<img>` element it may be desirable for the generated element to include additional attributes to provide styling or interaction qualities.  The optional `imgAttributes` value can be used to provide such additional attributes which will be included in the generated `<img>` element in the DOM.

Usage:

1. Include the ImageAttribute model in your .ts
```typescript
import { ImageAttribute } from 'ionic-image-loader'
  1. Generate an array of ImageAttribute objects
var imageAttributes: ImageAttribute[] = [];
imageAttributes.push({
  element: 'class',
  value: 'circle-photo'
})
  1. Include the imgAttributes element in the img-loader element of your HTML
 <img-loader [src]="..." useImg [imgAttributes]="imageAttributes"> </img-loader>
  1. The generated <img> tag will be rendered with the specified attributes
  <img src="..." class="circle-photo">

Contribution

  • Having an issue? or looking for support? Open an issue and we will get you the help you need.
  • Got a new feature or a bug fix? Fork the repo, make your changes, and submit a pull request.

Support this project

If you find this project useful, please star the repo to let people know that it's reliable. Also, share it with friends and colleagues that might find this useful as well. Thank you :smile: