Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎨 Adjust image resolution #1941 #2017

Merged
merged 5 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion web/lib/hooks/useSanityLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export const useSanityLoader = (image: ImageWithAlt, maxWidth: number, aspectRat
? Math.round(width * aspectRatio)
: Math.round(width * (cropped.height / cropped.width))

return imageUrlBuilder.width(width).height(height).auto('format').quality(70)
return imageUrlBuilder.width(width).height(height).auto('format').quality(100)
padms marked this conversation as resolved.
Show resolved Hide resolved
},
})
21 changes: 6 additions & 15 deletions web/pageComponents/cards/MagazineCard.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Card } from '@components'
import { CSSProperties } from 'react'
import styled from 'styled-components'
import { Flags } from '../../common/helpers/datasetHelpers'
import Image, { Ratios } from '../shared/SanityImage'
import { ImageWithAlt, MagazineCardData } from '../../types/types'
import { MagazineCardData } from '../../types/types'

const { Title, Header, Action, Arrow, Media, CardLink } = Card

Expand Down Expand Up @@ -43,24 +42,16 @@ type MagazineCardProp = {
}

const getThumbnail = (data: MagazineCardData) => {
const { openGraphImage, heroImage, hero } = data
const { heroImage } = data

if (!heroImage?.asset && !openGraphImage?.asset) return false
if (!heroImage?.asset) return false

return (
<Image
image={
(Flags.IS_DEV
? hero?.figure?.asset
? hero.figure
: openGraphImage
: heroImage?.asset
? heroImage
: openGraphImage) as ImageWithAlt
}
maxWidth={400}
image={heroImage}
maxWidth={700}
aspectRatio={Ratios.NINE_TO_SIXTEEN}
sizes="(max-width: 360px) 315px,(max-width: 600px) 550px,(max-width: 700px) 310px,450px"
sizes="(min-width: 1000px) 400px, (min-width: 440px) 335px, 82.5vw"
/>
)
}
Expand Down
2 changes: 1 addition & 1 deletion web/pageComponents/cards/NewsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const NewsCard = ({ data, fitToContent = false, ...rest }: NewsCardProp) => {
image={heroImage.image}
maxWidth={400}
aspectRatio={Ratios.NINE_TO_SIXTEEN}
sizes="(max-width: 360px) 315px,(max-width: 600px) 550px,(max-width: 700px) 310px,450px"
sizes="(min-width: 1780px) calc(-1.72vw + 401px), (min-width: 1340px) calc(17.86vw + 58px), 276px"
/>
)}
</Media>
Expand Down
2 changes: 1 addition & 1 deletion web/pageComponents/cards/PeopleCard/PeopleCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ const PeopleCard = ({ data, hasSectionTitle, orientation = 'portrait', ...rest }
>
<StyledMedia>
<ImageContainer>
{image && <RoundedImage image={image} maxWidth={200} aspectRatio={Ratios.ONE_TO_ONE} />}
{image && <RoundedImage image={image} maxWidth={400} aspectRatio={Ratios.ONE_TO_ONE} quality={100} />}
</ImageContainer>
</StyledMedia>
<TextContent style={{ '--text-height': orientation === 'portrait' ? '100%' : 'auto' } as CSSProperties}>
Expand Down
9 changes: 1 addition & 8 deletions web/pageComponents/cards/TopicPageCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,7 @@ const TopicPageCard = ({ data, fitToContent = false, ...rest }: TopicPageCardPro
}
>
<Media>
{thumbnail && (
<Image
image={thumbnail}
maxWidth={400}
aspectRatio={Ratios.NINE_TO_SIXTEEN}
sizes="(max-width: 360px) 315px,(max-width: 600px) 550px,(max-width: 700px) 310px,450px"
/>
)}
{thumbnail && <Image image={thumbnail} maxWidth={400} aspectRatio={Ratios.NINE_TO_SIXTEEN} sizes="220px" />}
</Media>
<Header>
<Title>{pageTitle}</Title>
Expand Down
4 changes: 0 additions & 4 deletions web/pageComponents/searchIndexPages/magazineIndex/Hits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ export const Hits = forwardRef<HTMLDivElement>(({ ...rest }, ref) => {
tags: hit.magazineTags,
heroImage: hit.heroImage,
heroType: hit.heroType,
hero: {
figure: hit.heroImage,
type: hit.heroType,
},
}
return <StyledMagazineCard key={hit.objectID} data={data as MagazineCardData} />
})}
Expand Down
2 changes: 1 addition & 1 deletion web/pageComponents/shared/Hero/FiftyFiftyHero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const FiftyFiftyHero = ({ title, ingress, link, background, figure, isBig
{figure && (
<Image
maxWidth={4096}
sizes="(max-width: 800px) 100vw, 800px"
sizes="(min-width: 760px) 50vw, 100vw"
image={figure.image}
fill
style={{ objectFit: 'cover' }}
Expand Down
9 changes: 2 additions & 7 deletions web/pageComponents/shared/Quote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,10 @@ const Quote = ({ data: { quote, authorTitle, author, image, designOptions } }: {
{image?.asset && (
<PullQuote.Media>
<Image
maxWidth={220}
maxWidth={242}
aspectRatio={Ratios.ONE_TO_ONE}
image={image}
sizes="
(max-width: 340px) 80px,
(max-width: 600px) 86px,
(max-width: 1440px) 164px,
220px
"
sizes="(min-width: 2280px) 242px, (min-width: 800px) calc(3.29vw + 168px), calc(1.67vw + 75px)"
/>
</PullQuote.Media>
)}
Expand Down
8 changes: 1 addition & 7 deletions web/pageComponents/topicPages/Figure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,7 @@ const FullWidthImage = ({ data, anchor }: TeaserProps) => {
<Image
image={image}
maxWidth={920}
sizes="(max-width: 360px) 313px,
(max-width: 600px) 415px,
(max-width: 950px) 550px,
(max-width: 1250px) 655px,
(max-width: 1450px) 730px,
(max-width: 1700px) 825px,
920px"
sizes="(min-width: 2060px) 920px, (min-width: 440px) calc(34.56vw + 215px), calc(76.67vw + 38px)"
/>
{(caption || attribution) && (
<FigureCaption>
Expand Down
3 changes: 0 additions & 3 deletions web/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,7 @@ export type MagazineCardData = {
slug: string
title: string | PortableTextBlock[]
tags?: string[]
openGraphImage?: ImageWithAlt
heroImage?: ImageWithAlt
heroType?: HeroTypes
hero?: HeroType
}

export type FeaturedContentData = {
Expand Down