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 🙏

© 2026 – Pkg Stats / Ryan Hefner

strapi-plugin-image-placeholder

v0.1.0

Published

Create Base64 Image Placeholder

Downloads

19

Readme

Image Placeholder (Strapi v5 plugin)

Create a Base64 image placeholder for any newly created or updated image stored on S3 (or any URL‑accessible storage). The plugin adds a placeholder field to plugin::upload.file and automatically fills it during lifecycle events.

This is useful for blurred image previews while the full image loads on the client.

Features

  • Auto‑generates Base64 placeholders on image create/update.
  • Extends plugin::upload.file with a placeholder text attribute.
  • Uses plaiceholder under the hood.
  • Supports remote/public URLs (e.g., S3 public URLs).

Requirements

  • Strapi v5.x (tested with @strapi/strapi@^5.23.3).
  • Upload plugin enabled (plugin::upload).
  • Publicly accessible image URLs from your storage provider (or your server must be able to fetch them).
  • Node 18+.

Installation

Install from npm after publishing your package. The current package name is placeholder. If you publish under a different name (e.g. strapi-plugin-image-placeholder), replace accordingly.

  • npm: npm install placeholder
  • yarn: yarn add placeholder
  • pnpm: pnpm add placeholder

Enable The Plugin

Add the plugin to your Strapi project’s config/plugins.ts and provide its configuration. The size option is required and validated (min: 4, max: 64). It is passed to plaiceholder.

Example config/plugins.ts:

import type { Core } from '@strapi/strapi';

export default ({ env }: { env: Core.Env }) => ({
  // ...other plugins
  placeholder: {
    enabled: true,
    config: {
      // Required: integer between 4 and 64
      size: 8,
    },
  },
});

There is also a ready‑to‑copy example at examples/config/plugins.ts in this repo.

How It Works

  • On register, the plugin augments plugin::upload.file with a placeholder text attribute.
  • On beforeCreate and beforeUpdate lifecycles for plugin::upload.file:
    • If the file is an image and has a resolvable url, the plugin fetches the image bytes.
    • It generates a Base64 placeholder using plaiceholder and stores it in file.placeholder.

Accessing The Placeholder

When you fetch files (REST or GraphQL), the placeholder field will be available on the upload.file entries. Example:

{
  "id": 1,
  "url": "https://your-bucket.s3.amazonaws.com/path/to/image.jpg",
  "mime": "image/jpeg",
  "placeholder": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQ..."
}

You can use this Base64 string in your frontend as a blurred preview.

Configuration

Currently supported options (under config):

  • size (number, required): Controls the size fed to plaiceholder (range 4–64). Smaller values are blurrier and faster; larger values are sharper with larger Base64 strings.

Example:

placeholder: {
  enabled: true,
  config: {
    size: 12,
  },
}

Notes and Limitations

  • The plugin fetches the image from its url on your Strapi server. Ensure the URL is accessible from the server (public S3 or proper network/VPC access). For private S3, consider generating signed URLs that Strapi can fetch during lifecycles.
  • Only files with mime starting with image/ and a truthy url are processed.
  • Errors during fetching or placeholder generation are logged and the placeholder is set to null.

Troubleshooting

  • Validation error about size:
    • Ensure you provided size in config/plugins.ts and it’s between 4 and 64.
  • Upload plugin not installed:
    • Install and enable @strapi/plugin-upload. The placeholder plugin depends on it.
  • Placeholders not generated for updates:
    • The plugin merges missing url/mime from the existing file on update, but if the URL is still not reachable from the server, generation will be skipped or fail.
  • Large images or slow network:
    • Consider a smaller size to reduce processing time and Base64 length.

Security & Performance

  • Your server fetches the image via fetch(url). Avoid exposing private buckets without proper access control.
  • Generating placeholders adds processing per upload/update; tune size to balance quality and speed.

License

MIT © Kian Tavakoli