-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Custom space avatar images #45148
Custom space avatar images #45148
Changes from 19 commits
22874e8
af4d621
de8cea4
e56ec19
b53846f
bb43112
b6ab35e
8bfac6e
46df7e9
9f25e11
6bca754
4a288e6
e0b9d00
8bd3e2d
85cc320
b3b704a
d9c8e82
4d3f686
1a8c8b1
060eadb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,10 @@ experimental[This functionality is *experimental* and may be changed or removed | |
`color`:: | ||
(Optional, string) Specifies the hexadecimal color code used in the space avatar. By default, the color is automatically generated from the space name. | ||
|
||
`imageUrl`:: | ||
(Optional, string) Specifies the data-url encoded image to display in the space avatar. If specified, `initials` will not be displayed, and the `color` will be visible as the background color for transparent images. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I've been changing every To make the second sentence active, I would change it to "... |
||
For best results, your image should be 64x64. Images will not be optimized by this API call, so care should be taken when using custom images. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To make the second sentence active, I would change it to "Images are not optimized by this API call." Could we specify what "so care should be taken when using custom images" means? Or maybe change it to "Images are not optimized by this API call. Use custom images sparingly." There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
How about something like this? |
||
|
||
[[spaces-api-put-response-codes]] | ||
==== Response codes | ||
|
||
|
@@ -52,7 +56,8 @@ PUT /api/spaces/space/marketing | |
"description" : "This is the Marketing Space", | ||
"color": "#aabbcc", | ||
"initials": "MK", | ||
"disabledFeatures": [] | ||
"disabledFeatures": [], | ||
"imageUrl": "" | ||
} | ||
-------------------------------------------------- | ||
// KIBANA |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { fromByteArray } from 'base64-js'; | ||
|
||
export const imageTypes = ['image/svg+xml', 'image/jpeg', 'image/png', 'image/gif']; | ||
|
||
export function encode(data: any | null, type = 'text/plain') { | ||
// use FileReader if it's available, like in the browser | ||
if (FileReader) { | ||
return new Promise<string>((resolve, reject) => { | ||
const reader = new FileReader(); | ||
reader.onloadend = () => resolve(reader.result as string); | ||
reader.onerror = err => reject(err); | ||
reader.readAsDataURL(data); | ||
}); | ||
} | ||
|
||
// otherwise fall back to fromByteArray | ||
// note: Buffer doesn't seem to correctly base64 encode binary data | ||
return Promise.resolve(`data:${type};base64,${fromByteArray(data)}`); | ||
friol marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
url
should beURL
I've been changing every
If specified
toWhen specified
, but totally up to you if it makes sense to change here.To make the second sentence active, I would change it to "...
initials
are not displayed, and thecolor
is visible as the background color for transparent images."