Commit 3b7e851d authored by samuel.mortenson's avatar samuel.mortenson Committed by Samuel Mortenson

Issue #3110663 by samuel.mortenson: Metatags for twitter:image and og:image not respected

parent 4c92c1e4
......@@ -396,6 +396,21 @@ class StaticGenerator implements StaticGeneratorInterface {
$paths[] = $node->getAttribute('href');
}
}
$meta_files = [
'twitter:image',
'twitter:player:stream',
'og:image',
'og:video',
'og:audio',
'og:image:url',
'og:image:secure_url',
];
/** @var \DOMElement $node */
foreach ($document->getElementsByTagName('meta') as $node) {
if ((in_array($node->getAttribute('property'), $meta_files, TRUE) || in_array($node->getAttribute('name'), $meta_files, TRUE)) && $node->hasAttribute('content')) {
$paths[] = $node->getAttribute('content');
}
}
/** @var \DOMElement $node */
foreach ($document->getElementsByTagName('a') as $node) {
if ($node->hasAttribute('href')) {
......
......@@ -40,6 +40,8 @@ class TestController extends ControllerBase {
<a href='/path/with/destination?destination=foo&bar=baz'></a>
<iframe src='/random/iframe'></iframe>
<img src=\"data:image/jpeg;base64,x\" />
<meta name=\"twitter:image\" content=\"/twitter_image.png\" />
<meta property=\"og:image\" content=\"/og_image.png\" />
<svg><use xlink:href='/use.svg'></use></svg>",
'#attached' => [
'library' => [
......
......@@ -224,6 +224,8 @@ class StaticGeneratorTest extends TestBase {
$this->assertContains('/random/iframe', $invoke_paths);
$this->assertContains('/core/assets/vendor/html5shiv/html5shiv.min.js?v=3.7.3', $invoke_paths);
$this->assertContains('/use.svg', $invoke_paths);
$this->assertContains('/twitter_image.png', $invoke_paths);
$this->assertContains('/og_image.png', $invoke_paths);
$this->assertNotContains('data:image/jpeg;base64,x', $invoke_paths);
$static->exportPaths($invoke_paths);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment