Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The current implementation of the field doesn't allow for alpha values (either #00000000 - 8 characters) or an RGB implementation such as { r: 0, g: 82, b: 148, a: 0.75 }.
This is possible using the same color picker (http://labs.abeautifulsite.net/jquery-minicolors/#demos). Just needs to be integrated into the module.
Comment | File | Size | Author |
---|---|---|---|
#3 | colorfield-add-alpha-widget-2375017-3.patch | 7.96 KB | laughnan |
#1 | colorfield-add-alpha-widget-2375017-1.patch | 7.48 KB | laughnan |
Comments
Comment #1
laughnanPatch for adding a new RGBA field widget.
- Changed the field to include a second column for alpha (not required, defaults to 1.0 which is completely opaque).
- Added a new widget for the minicolors alpha support
- Updated the minicolors widget alter and added another JS file to handle alpha
Comment #2
laughnanComment #3
laughnanUpdated patch. Displayed the widget incorrectly for multiple values of the colorfield picker. This fixes that.
Comment #4
digitoolmedia CreditAttribution: digitoolmedia commentedgiven that I am not an expert in Drupal code, I applied the patch to manage the opacity, but the result I get when I use the widget 'Color code with Alpha' is to delete the record in field_data_field_COLORFIELD_NAME table for the node where it is used.
The problem is saving, not the recovery of rgb/opacity, if I manually create such a record.
MiniColor widget works well.
Comment #5
laughnanthat's great feedback @digitoolmedia!
Comment #6
laughnanComment #7
laughnanComment #8
texas-bronius CreditAttribution: texas-bronius commentedIs this true only for existing content? And on next save, does it actually retain RGB and Alpha? Does it maybe work out of the box when installed fresh and only break on existing installations when the patch is applied? Is there maybe a schema update missing from a hook_update_n?