Giter VIP home page Giter VIP logo

netlify-cms-widget-image-dimensions's Introduction

netlify-cms-widget-image-dimensions

A modified Netlify CMS image widget that allows restricting image dimensions.

Warning: Very hacky and experimental.

Install

As an npm package:

npm install --save netlify-cms-widget-image-dimensions
import { ImageDimensionsControl, ImageDimensionsPreview, ImageDimensionsSchema } from 'netlify-cms-widget-image-dimensions'

CMS.registerWidget('image_dimensions', ImageDimensionsControl, ImageDimensionsPreview, ImageDimensionsSchema)

Via script tag:

<script src="https://unpkg.com/netlify-cms-widget-image-dimensions@^1.0.0"></script>

<script>
  CMS.registerWidget('image_dimensions', ImageDimensionsControl, ImageDimensionsPreview, ImageDimensionsSchema)
</script>

How to use

Add to your Netlify CMS configuration:

    fields:
      - { name: <fieldname>, label: <fieldlabel>, widget: image_dimensions }

To set a limit on the minimum width/height of the image, use min_width and min_height. To set the width/height to be an exact value, use exact_width and exact_height. If you configure both min_width and exact_width then min_width will be ignored, and likewise for min_height and exact_height.

To configure the validation/error message (highly recommended), use validation.

    fields:
      - name: <fieldname>
        label: <fieldlabel>
        widget: image_dimensions
        exact_width: 300
        exact_height: 200
        validation: "Image must be 300x200px"

netlify-cms-widget-image-dimensions's People

Stargazers

 avatar  avatar

Watchers

 avatar  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.