From e24d0bd522a3611140352bf5cd1623ca032be60b Mon Sep 17 00:00:00 2001 From: Daniel Bachler Date: Tue, 31 Oct 2023 15:56:33 +0100 Subject: [PATCH] :hammer: normalize thumbnail urls so that they never point to owid.cloud --- baker/postUpdatedHook.ts | 2 +- db/syncPostsToGrapher.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/baker/postUpdatedHook.ts b/baker/postUpdatedHook.ts index 2a3bad329e7..93b5793beb9 100644 --- a/baker/postUpdatedHook.ts +++ b/baker/postUpdatedHook.ts @@ -76,7 +76,7 @@ const syncPostToGrapher = async ( p.*, pwa.authors, fr.created_at as created_at, - (SELECT guid FROM wp_posts WHERE ID = fi.featured_image_id) AS featured_image + regexp_replace((SELECT guid FROM wp_posts WHERE ID = fi.featured_image_id), '^https://owid.cloud/(app|wp-content)/', 'https://ourworldindata.org/wp-content/') AS featured_image from wp_posts p left join post_ids_with_authors pwa on pwa.id = p.id left join first_revision fr on fr.post_id = p.id diff --git a/db/syncPostsToGrapher.ts b/db/syncPostsToGrapher.ts index 7d7dc2bb566..a8d6be458bb 100644 --- a/db/syncPostsToGrapher.ts +++ b/db/syncPostsToGrapher.ts @@ -177,7 +177,8 @@ const syncPostsToGrapher = async (): Promise => { p.*, pwa.authors as authors, fr.created_at as created_at, - (SELECT guid FROM wp_posts WHERE ID = fi.featured_image_id) AS featured_image + -- select the featured image url and normalize the to point to our full domain at the wp-content folder + regexp_replace((SELECT guid FROM wp_posts WHERE ID = fi.featured_image_id), '^https://owid.cloud/(app|wp-content)/', 'https://ourworldindata.org/wp-content/') AS featured_image from wp_posts p left join post_ids_with_authors pwa on p.ID = pwa.ID left join first_revision fr on fr.post_id = pwa.ID