diff --git a/client/modules/Preview/EmbedFrame.jsx b/client/modules/Preview/EmbedFrame.jsx
index 4b2ad60d9b..46e5940836 100644
--- a/client/modules/Preview/EmbedFrame.jsx
+++ b/client/modules/Preview/EmbedFrame.jsx
@@ -8,7 +8,6 @@ import decomment from 'decomment';
import { resolvePathToFile } from '../../../server/utils/filePath';
import getConfig from '../../utils/getConfig';
import {
- MEDIA_FILE_REGEX,
MEDIA_FILE_QUOTED_REGEX,
STRING_REGEX,
PLAINTEXT_FILE_REGEX,
@@ -18,6 +17,7 @@ import {
import { getAllScriptOffsets } from '../../utils/consoleUtils';
import { registerFrame } from '../../utils/dispatcher';
import { createBlobUrl } from './filesReducer';
+import resolvePathsForElementsWithAttribute from '../../../shared/resolveUtils';
let objectUrls = {};
let objectPaths = {};
@@ -34,19 +34,6 @@ const Frame = styled.iframe`
`}
`;
-function resolvePathsForElementsWithAttribute(attr, sketchDoc, files) {
- const elements = sketchDoc.querySelectorAll(`[${attr}]`);
- const elementsArray = Array.prototype.slice.call(elements);
- elementsArray.forEach((element) => {
- if (element.getAttribute(attr).match(MEDIA_FILE_REGEX)) {
- const resolvedFile = resolvePathToFile(element.getAttribute(attr), files);
- if (resolvedFile && resolvedFile.url) {
- element.setAttribute(attr, resolvedFile.url);
- }
- }
- });
-}
-
function resolveCSSLinksInString(content, files) {
let newContent = content;
let cssFileStrings = content.match(STRING_REGEX);
@@ -218,7 +205,12 @@ function injectLocalFiles(files, htmlFile, options) {
base.href = `${window.origin}${basePath}${basePath.length > 1 && '/'}`;
sketchDoc.head.appendChild(base);
+ // Resolve paths for elements with the 'src' attribute
+ // This updates the 'src' attribute of elements (e.g.,
,