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

universal-img-component

v2.0.0

Published

🌟 A versatile React component for handling images with ease! πŸ“Έ Supports multiple modes: convert images to Base64 πŸ”„, optimize with CDN 🌐, create text-based images πŸ“, and use Next.js optimization πŸš€. Perfect for any project needing dynamic image manage

Downloads

42

Readme

Universal Image Component πŸ“Έ

universal-img-component is a versatile React component that simplifies handling images in various modes, including Base64, CDN, text-based images, and Next.js optimization. Perfect for any project needing dynamic image handling!

npm Visitors GitHub issues GitHub discussions GitHub stars GitHub forks GitHub license

Features ✨

  • Normal Mode: Display images using standard URLs.
  • Cloudinary Mode (Recommended): Use Cloudinary for image transformations and optimizations.
  • Base64 Mode: Convert images to Base64 format.
  • CDN Mode: Optimize images using a CDN service.
  • Text Mode: Create text-based images with Statically’s Open Graph service.
  • TextBase Mode: Convert text-based image URLs to Base64.
  • Next Mode: Use Next.js Image component for optimization (in a Next.js environment).

Installation πŸš€

To get started, install the package via npm or yarn:

npm install universal-img-component
# or
yarn add universal-img-component

Usage πŸ“š

Importing the Component

Import the Img component:

import Img from 'universal-img-component';

Normal Mode πŸ–ΌοΈ

Displays an image using the standard URL:

<Img src="https://via.placeholder.com/150" alt="placeholder" mode="normal" width="150" height="150" />

Base64 Mode πŸ”„

Converts the image to Base64 format:

<Img src="https://via.placeholder.com/150" alt="placeholder" mode="base64" width="150" height="150" />

CDN Mode 🌐

Uses a CDN to serve and optimize the image:

<Img
  src="https://via.placeholder.com/150"
  alt="placeholder"
  mode="cdn"
  width="300"
  height="300"
  format="webp"
  fit="cover"
/>

Text Mode πŸ“

Generates an image with text using Statically’s Open Graph service:

<Img
  src=""
  mode="text"
  text="Hello World"
  theme="dark"
  fontsize="24px"
  width="800"
  height="400"
  alt="Open Graph Image"
/>

TextBase Mode πŸ–‹οΈ

Generates a text-based image URL and converts it to Base64 format:

<Img
  src=""
  mode="textbase"
  text="Hello World"
  theme="dark"
  fontsize="80px"
  width="800"
  height="400"
  alt="Base64 Open Graph Image"
/>

Next Mode πŸš€

Uses Next.js Image component for optimized handling:

<Img src="https://via.placeholder.com/150" alt="placeholder" mode="next" width={150} height={150} />

Cloudinary Mode ☁️

Uses Cloudinary for image transformations and optimizations:

<Img
  src="https://res.cloudinary.com/demo/image/upload/sample.jpg"
  mode="cloudinary"
  width="300"
  height="300"
  format="webp"
  fit="cover"
/>

Props πŸ› οΈ

  • src (string): The source URL or text for the image.
  • mode (string): Mode to use. Options: "normal", "base64", "cdn", "text", "textbase", "next", "cloudinary". Default is "normal".
  • width (string|number): Width of the image. Applies to all modes.
  • height (string|number): Height of the image. Applies to all modes.
  • format (string): Format of the image in CDN and Cloudinary modes (e.g., "webp", "jpg", "png").
  • fit (string): Fit mode in CDN and Cloudinary modes (e.g., "cover", "contain", "fill", "inside", "outside").
  • text (string): Text for text modes ("text" and "textbase").
  • theme (string): Theme for text-based images (e.g., "dark"). Applies to text modes.
  • fontsize (string): Font size for text-based images (e.g., "24px"). Applies to text modes.

License πŸ“œ

This package is licensed under the MIT License. See the LICENSE file for more information.

Contact πŸ“«

For any questions or feedback, feel free to open an issue or join the discussion on GitHub Issues and GitHub Discussions. You can also reach out via email at [email protected].