Skip to content

Commit 9c4da7c

Browse files
author
Ilan Parmentier
authored
Missing crossorigin in html output
I can see the support of crossorigin attribute in header but not in the html ouput : /vendor/yireo/magento2-linkpreload/Link/Link.php function getHeader But in the navigator, I have a notice in web developer : A preload for '../Blank-Theme-Icons/Blank-Theme-Icons.woff2' is found, but is not used because the request credentials mode does not match. Consider taking a look at crossorigin attribute. This is my proposal to fix this issue.
1 parent 15397c9 commit 9c4da7c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Link/LinkParser.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,13 @@ private function processBody(HttpResponse $response)
110110
continue;
111111
}
112112

113-
$newTags[] = '<link rel="preload" as="' . $link->getType() . '" href="' . $link->getUrl() . '" />';
113+
$createTag = '<link rel="preload" as="' . $link->getType() . '"';
114+
if ($link->getType() === 'font') {
115+
$createTag .= ' crossorigin="anonymous"';
116+
}
117+
$createTag .= ' href="' . $link->getUrl() . '" />';
118+
119+
$newTags[] = $createTag;
114120
}
115121

116122
$body = preg_replace('^</title>^',"</title>\n" . implode("\n", $newTags) , $body, 1);

0 commit comments

Comments
 (0)