Skip to content

Commit

Permalink
🔨 normalize thumbnail urls so that they never point to owid.cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
danyx23 committed Oct 31, 2023
1 parent 17ba872 commit e24d0bd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion baker/postUpdatedHook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion db/syncPostsToGrapher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ const syncPostsToGrapher = async (): Promise<void> => {
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
Expand Down

0 comments on commit e24d0bd

Please sign in to comment.