Skip to content

Commit

Permalink
Merge pull request #2893 from owid/prominent-link-fix
Browse files Browse the repository at this point in the history
Fix thumbnails for prominent link to Graphers / Explorers
  • Loading branch information
ikesau authored Nov 7, 2023
2 parents c5bfa85 + 6d2226f commit c3132c5
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion site/gdocs/ProminentLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Image from "./Image.js"
import { useLinkedChart, useLinkedDocument } from "./utils.js"
import { DocumentContext } from "./OwidGdoc.js"
import { BlockErrorFallback } from "./BlockErrorBoundary.js"
import { BAKED_GRAPHER_EXPORTS_BASE_URL } from "../../settings/clientSettings.js"

export const ProminentLink = (props: {
url: string
Expand Down Expand Up @@ -61,6 +62,17 @@ export const ProminentLink = (props: {
: ""
}

const Thumbnail = ({ thumbnail }: { thumbnail: string }) => {
if (
thumbnail.startsWith(BAKED_GRAPHER_EXPORTS_BASE_URL) ||
thumbnail.endsWith("default-thumbnail.jpg")
) {
return <img src={thumbnail} />
} else {
return <Image filename={thumbnail} containerType="thumbnail" />
}
}

const anchorTagProps =
linkType === "url"
? { target: "_blank", rel: "noopener noreferrer" }
Expand All @@ -78,7 +90,7 @@ export const ProminentLink = (props: {
>
{thumbnail ? (
<div className="prominent-link__image span-sm-cols-3 span-md-cols-2">
<Image filename={thumbnail} containerType="thumbnail" />
<Thumbnail thumbnail={thumbnail} />
</div>
) : null}
<div className={textContainerClassName}>
Expand Down

0 comments on commit c3132c5

Please sign in to comment.