• HEX: #96d1e3
  • RGB: rgb(150, 209, 227)
  • HEX: #dbf3f4
  • RGB: rgb(219, 243, 244)
  Download

What is Swatchify?

Swatchify is a WordPress plugin that grabs an image from a post or image file and creates a swatch to go with it.

Implement Swatchify

In its simplest form Swatchify is a shortcode. This shortcode can be used throughout your theme on any post, page, or custom post type in either the post content or in the php.

When implemented on a page Swatchify will grab an image, extract the colors, associate those colors to your post using custom color taxonomies and meta, and then output a swatch with the style of your choosing.

Base Shortcode

[swatchify]

With Parameters

[swatchify style="" image="" quality=""]

Style

  • Requirement: Optional
  • Default: default
  • Options: (default | small-circles | small-squares | small-diamonds | small-bar | medium-bar | tall-bar full-bar | collage-vertical | collage-horizontal)

The style is what determins how your swatch will look. Choose from one of the piped options above.

Image

  • Requirement: Optional
  • Default: null
  • Options: Any properly formatted image link.

If provided swatchify will use this image to create your swatch. If this parameter is not provided swatchify grabs the featured image attached to your post. If there is no featured image then it looks for an image in the body text of the post. If there is no image to be found the swatch will fail.

Quality

  • Requirement: Optional
  • Default: 10
  • Options: Any number 1-20

Depending on where you are placing swatchify, and how many swatches you are trying to generate you will want to change the quality of the image parsing. 1 = highest, 10 = default, and you can go higher if you wish to spend less memory on swatch generation.


In Theme Files

<?php echo do_shortcode('[swatchify]'); ?>

Examples

Default

[swatchify style="default"]
  • HEX: #96d1e3
  • RGB: rgb(150, 209, 227)
  • HEX: #dbf3f4
  • RGB: rgb(219, 243, 244)

Small Circles

[swatchify style="small-circles"]
  • HEX: #96d1e3
  • RGB: rgb(150, 209, 227)
  • HEX: #dbf3f4
  • RGB: rgb(219, 243, 244)

Small Squares

[swatchify style="small-squares"]
  • HEX: #96d1e3
  • RGB: rgb(150, 209, 227)
  • HEX: #dbf3f4
  • RGB: rgb(219, 243, 244)

Small Diamonds

[swatchify style="small-diamonds"]
  • HEX: #96d1e3
  • RGB: rgb(150, 209, 227)
  • HEX: #dbf3f4
  • RGB: rgb(219, 243, 244)

Small Bar

[swatchify style="small-bar"]
  • HEX: #96d1e3
  • RGB: rgb(150, 209, 227)
  • HEX: #dbf3f4
  • RGB: rgb(219, 243, 244)

Medium Bar

[swatchify style="medium-bar"]
  • HEX: #96d1e3
  • RGB: rgb(150, 209, 227)
  • HEX: #dbf3f4
  • RGB: rgb(219, 243, 244)

Tall Bar

[swatchify style="tall-bar"]
  • HEX: #96d1e3
  • RGB: rgb(150, 209, 227)
  • HEX: #dbf3f4
  • RGB: rgb(219, 243, 244)

Full Bar

[swatchify style="full-bar"]
  • HEX: #96d1e3
  • RGB: rgb(150, 209, 227)
  • HEX: #dbf3f4
  • RGB: rgb(219, 243, 244)

Collage Vertical

[swatchify style="collage-vertical" image="http://www.sparqvault.com/wp-content/uploads/2016/12/tumblr_nk0115ZNox1sxuwguo1_1280.jpg" quality="12"]
  • HEX: #e5dfd8
  • RGB: rgb(229, 223, 216)
  • HEX: #998c80
  • RGB: rgb(153, 140, 128)

Collage Horizontal

[swatchify style="collage-horizontal" image="http://www.sparqvault.com/wp-content/uploads/2016/12/tumblr_o0s3b6J5JV1tvh80lo1_1280.jpg" quality="12"]

In The Wild

Made Possible With...

This plugin wouldn't exist without Kevin Subileua's Color Thief PHP class, the WordPress Plugin Boilerplate Generator by Devin Vinson, kevinlebrun's Colors.php, and colorName.php from this dude, and of course WordPress!.

Ideas I'm Working On...

  • Shortcode to pull specific dominant colors.
  • How to make dominant colors more prominant.

Comments / Suggestions

Subscribe for More!


I send out a monthly newsletter on various topics.

Take a moment to enter your details, and you can select the news you would like to have delivered to your inbox!