Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: add dominant color attribute to chat image uploads #24214

Merged
merged 3 commits into from Nov 2, 2023

Conversation

dbattersby
Copy link
Contributor

@dbattersby dbattersby commented Nov 2, 2023

When uploading images, they are assigned a dominant color which gets used in various places, such as Discourse Hub and the new lightbox. Previously in chat we didn't assign this attribute, so it was defaulting to a null value. We did however use it as an inline CSS style for the image background (which is visible while the image is downloaded).

This change adds data-dominant-color to the uploaded image in chat and uses it correctly within lightbox.

@github-actions github-actions bot added the chat PRs which include a change to Chat plugin label Nov 2, 2023
@@ -54,7 +54,10 @@ export async function processHTML({ container, selector, clickTarget }) {
.querySelector(SELECTORS.FILE_DETAILS_CONTAINER)
?.innerText.trim() || null;

const _dominantColor = innerImage.dataset?.dominantColor || null;
const _dominantColor =
item.dataset?.dominantColor ??
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In chat we don't have a wrapper for the image so the attribute is directly on the target image.

Copy link
Contributor

@jjaffeux jjaffeux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dbattersby dbattersby merged commit 65759c1 into main Nov 2, 2023
14 checks passed
@dbattersby dbattersby deleted the add-dominant-color-to-chat-images branch November 2, 2023 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chat PRs which include a change to Chat plugin
3 participants