Git Product home page Git Product logo

placeholders.dev's Introduction

Generate super-fast placeholder images in 270+ edge locations, powered by Cloudflare Workers 350x150 placeholder image200x100 placeholder image140x100 placeholder image 1055x100 placeholder image

Deploy to Cloudflare Workers

Info

placeholders.dev generates custom placeholder images on the fly, such as the examples above. All of these images are generated on Cloudflare's Edge, at 200+ locations, ensuring the best possible performance for all of your users. All images are cached for lengthy periods of time.

Technology

This project makes use of Cloudflare Workers, and Cloudflare Workers Sites via Workers KV. It also implements a HTMLRewriter to update the total Cloudflare PoPs in multiple locations.

Available API Options

  • width
    • Width of generated image. Defaults to 300.
  • height
    • Height of generated image. Defaults to 150.
  • text
    • Text to display on generated image. Defaults to the image dimensions.
  • fontFamily
    • Font to use for the text. Defaults to sans-serif.
  • fontWeight
    • Font weight to use for the text. Defaults to bold.
  • fontSize
    • Font size to use for the text. Defaults to 20% of the shortest image dimension, rounded down.
  • dy
    • Adjustment applied to the dy attribute of the text element to appear vertically centered. Defaults to 35% of the font size.
  • bgColor
    • Background color of the image. Defaults to #ddd
  • textColor
    • Color of the text. For transparency, use an rgba or hsla value. Defaults to rgba(0,0,0,0.5)

Example URL: https://images.placeholders.dev/?width=1055&height=100&text=Made%20with%20placeholders.dev&bgColor=%23f7f6f6&textColor=%236d6e71

Dev

Prerequisites

Wrangler

wrangler is a CLI tool from Cloudflare, designed to push projects to Cloudflare Workers. See Cloudflare's documentation for more information.

Install it with npm:

  • npm i @cloudflare/wrangler -g

After install run wrangler config and follow the prompts to add your Wrangler API token. Follow the instructions in Cloudflare's docs for information on this.

Build

  • wrangler build

Run

  • npm run start:dev (this will use cloudworker to run a server on localhost:3000 mimicking the API Worker)

or

  • npm run publish (push to placeholders-dev workers.dev)

or

  • npm run publish:staging (push to placeholders-staging workers.dev)

or

  • npm run publish:preview (push to Cloudflare Workers preview builder)

Production

  • npm run publish:prod (publishes to placeholders.dev via Workers)

placeholders.dev's People

Contributors

cherry avatar dependabot[bot] avatar tombyrer avatar kristianfreeman avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.