Skip to content

Commit d757a05

Browse files
committed
Add support for svgs that use data urls
1 parent f057984 commit d757a05

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

.changeset/breezy-terms-float.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@plexinc/react-lightning": patch
3+
---
4+
5+
Adds support for svgs that use data urls

packages/react-lightning/src/element/LightningImageElement.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ export class LightningImageElement extends LightningViewElement<
2929

3030
public set src(v) {
3131
this.node.src = v;
32+
33+
// Attempt to set the svg imageType for data urls if not already set.
34+
// Lightning doesn't handle svgs that are data urls, so this adds support
35+
// for that.
36+
if (this.node.imageType == null && v) {
37+
const src = v.toLowerCase();
38+
const isSvg =
39+
src.endsWith('.svg') || src.startsWith('data:image/svg+xml,');
40+
41+
this.setNodeProp('imageType', isSvg ? 'svg' : null);
42+
}
3243
}
3344

3445
protected override _handleTextureLoaded(event: NodeLoadedPayload): void {

0 commit comments

Comments
 (0)