Save images offline, in the snapshot (#770)
* Implemented image restore from rr_dataURL * Implement saving images in the snapshot * Fixed image saving, added a test * Rename data-src to data-rrweb-src * Updated the guide * Rename recordImages to inlineImages and try catch
This commit is contained in:
committed by
GitHub
parent
dd2cdedcd6
commit
151debad4a
@@ -226,18 +226,24 @@ function buildNode(
|
||||
ctx.drawImage(image, 0, 0, image.width, image.height);
|
||||
}
|
||||
};
|
||||
} else if (tagName === 'img' && name === 'rr_dataURL') {
|
||||
const image = (node as HTMLImageElement);
|
||||
if (!image.currentSrc.startsWith('data:')) {
|
||||
// backup original img src
|
||||
image.setAttribute('data-rrweb-src', image.currentSrc);
|
||||
image.src = value;
|
||||
}
|
||||
image.removeAttribute(name);
|
||||
}
|
||||
|
||||
if (name === 'rr_width') {
|
||||
(node as HTMLElement).style.width = value;
|
||||
}
|
||||
if (name === 'rr_height') {
|
||||
} else if (name === 'rr_height') {
|
||||
(node as HTMLElement).style.height = value;
|
||||
}
|
||||
if (name === 'rr_mediaCurrentTime') {
|
||||
} else if (name === 'rr_mediaCurrentTime') {
|
||||
(node as HTMLMediaElement).currentTime = n.attributes
|
||||
.rr_mediaCurrentTime as number;
|
||||
}
|
||||
if (name === 'rr_mediaState') {
|
||||
} else if (name === 'rr_mediaState') {
|
||||
switch (value) {
|
||||
case 'played':
|
||||
(node as HTMLMediaElement)
|
||||
|
||||
Reference in New Issue
Block a user