Dominant Color

설명

A WordPress plugin to automatically save the dominant color and a color palette for an attachment image into post_meta.

스크린샷

  • Shows the plugin in use on hellobrstl.com
  • Shows the plugin in use on hellobrstl.com
  • Shows the plugin in use on hellobrstl.com

설치

The dominant color and color palette is automatically saved on upload and edit to post meta.

You need to then use get_post_meta to retrieve the “dominant_color_hex” or “dominant_color_rgb” meta key. hex returns a string, including the #, rgb returns an array with key 0 as red, 1 as green, and 2 as blue.

Alternatively, you can use the meta keys “color_palette_rgb” and “color_palette_hex” to get an array of 8 colors that feature prominently in the image.

후기

2024년 4월 15일 2 replies
This plugin is perfect in its simplicity. Developers thought of everything, and it makes pages with images look beautiful. PLUS, if you don't like the color they pick to be dominant, you can choose another color from the image. So well thought out. I just wish Wordpress wouldn't bug me saying it hasn't been tested with the last 3 releases. It works perfectly, and probably will regardless of updates. Here's how I use it in a theme in case anyone reading this is struggling. if (has_post_thumbnail()) {$featured_image_id=get_post_thumbnail_id( );}$imageColor = get_color_data($featured_image_id, 'dominant_color_hex', 'true');$colorPaletteArray = get_post_meta ($featured_image_id, 'color_palette_hex', 'true');$complimentaryColor1 = $colorPaletteArray[0];$complimentaryColor2 = $colorPaletteArray[1];$complimentaryColor3 = $colorPaletteArray[2];$complimentaryColor4 = $colorPaletteArray[3]; And then I just assign $imageColor, and it's 4 complimentary colors, to the relevant divs in the template. Genius plugin, and thank you for creating it.
2019년 10월 29일
Useful plugin, please add function to bulk edit all images on gallery 🥰
2016년 9월 3일
Pulls out both the dominant color and a nice color palette. Far more efficient to do this calculation once on upload rather than via PHP or JavaScript when rendering the page. Perfect!
2016년 9월 3일
I had to search the post_meta table to find out how the 'dominant_override' meta_key - it would have been useful to find that in the release notes. A bulk calculate feature would be excellent - along with a way of colour picking the override from the posts screen in the WP Dashboard. Otherwise, perfect for what I need 🙂
모든 5 평가 읽기

기여자 & 개발자

“Dominant Color”(은)는 오픈 소스 소프트웨어입니다. 다음의 사람들이 이 플러그인에 기여하였습니다.

기여자

“Dominant Color”(이)가 3(으)로 번역되었습니다. 기여해 주셔서 번역자님께 감사드립니다.

자국어로 “Dominant Color”(을)를 번역하세요.

개발에 관심이 있으십니까?

코드 탐색하기는, SVN 저장소를 확인하시거나, 개발 기록RSS로 구독하세요.

변경이력

2.2.0

Modernise javascript for deprecated jQuery handlers
Update to latest version of PHP Color Thief
Bump version requirements to match color thief and a modern-ish WordPress (5.4+)

2.1.0

Support translated languages (Submit your translation at translate.wordpress.org!)

2.0.1

Fix a bug where loading our JS in the footer would cause a javascript error.

2.0

Add a colour picker to the attachment edit screen to override the dominant color with a custom pick.
The WordPress media gallery will now let you pick a dominant color override which will be returned in place of dominant_color_hex/rgb when set.
It’ll also let you generate a palette for legacy images uploaded before you installed the plugin.

1.0

Initial Build