Images missing in Twitter/X cards when using Glide prefix
URL in twitter:image meta tag is not recognized by Twitter/X, when statamic.seo-pro.assets.twitter_preset or statamic.seo-pro.assets.open_graph_preset config value is present, and image assets are stored in Digital Ocean spaces (S3-compatible). Removing both statamic.seo-pro.assets.twitter_preset and statamic.seo-pro.assets.open_graph_preset fixes the issue, but it's not ideal, since this doesn't let me use image optimization.
The URL generated by SEO Pro with presets enabled is like:
https://netzerocompare.com/img/containers/spaces/rare-earth-minerals.jpg/eeb3acd0207df1752a35e0afbfece7ab/rare-earth-minerals.jpg
<meta name="twitter:image" content="https://netzerocompare.com/img/containers/spaces/rare-earth-minerals.jpg/eeb3acd0207df1752a35e0afbfece7ab/rare-earth-minerals.jpg" />
and it's accessible, and similar style URLs work on other social media platforms (for example Facebook). However, Twitter/X seems to get confused, since it appears as malformed url - it contains rare-earth-minerals.jpg string twice.
When I comment out presets in seo-pro config file, the URL is generated in the following format:
https://netzerocompare.fra1.digitaloceanspaces.com/spaces/rare-earth-minerals.jpg
<meta name="twitter:image" content="https://netzerocompare.fra1.digitaloceanspaces.com/spaces/rare-earth-minerals.jpg" />
and in this format Twitter correctly shows the preview card.
This issue is pretty tough to reproduce, since it requires setting up DO Spaces, and can be tested only on publicly accessible URLs (Twitterbot needs to visit the page). And then, there's also an issue with Twitter/X caching the page source for an undefined period of time.
My seo-pro config file for reference (with presets commented out):
<?php
return [
'site_defaults' => [
'path' => base_path('content/seo.yaml'),
],
'assets' => [
'container' => 'spaces',
// 'twitter_preset' => [
// 'w' => 1200,
// 'h' => 600,
// ],
// 'open_graph_preset' => [
// 'w' => 1146,
// 'h' => 600,
// ],
],
'sitemap' => [
'enabled' => true,
'url' => 'sitemap.xml',
'expire' => 60,
'pagination' => [
'enabled' => true,
'url' => 'sitemap_{page}.xml',
'limit' => 100,
],
],
'humans' => [
'enabled' => true,
'url' => 'humans.txt',
],
'pagination' => [
'enabled_in_canonical_url' => true,
'enabled_on_first_page' => false,
],
'twitter' => [
'card' => 'summary_large_image',
],
'alternate_locales' => [
'enabled' => true,
'excluded_sites' => [],
],
'reports' => [
'queue_chunk_size' => 1000,
],
];