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

Use the image size information provided by the API instead of making head requests #551

Closed
obulat opened this issue May 20, 2022 · 1 comment
Labels
💻 aspect: code Concerns the software code in the repository ✨ goal: improvement Improvement to an existing user-facing feature 🟨 priority: medium Not blocking but should be addressed soon 🧱 stack: frontend Related to the Nuxt frontend ⛔ status: blocked Blocked & therefore, not ready for work

Comments

@obulat
Copy link
Contributor

obulat commented May 20, 2022

Blocked by https://github.com/WordPress/openverse-catalog/issues/521
Blocked by https://github.com/WordPress/openverse-api/issues/711

Problem

Currently, we are making a head request to the image source to get the image dimensions if they are not available in the API response. After the changes in the linked issues, we will get all the information from the API.

Description

We will need to delete the code that makes a head request to the image provider to get the image dimensions 🎉

@obulat obulat added 🟨 priority: medium Not blocking but should be addressed soon ✨ goal: improvement Improvement to an existing user-facing feature 💻 aspect: code Concerns the software code in the repository ⛔ status: blocked Blocked & therefore, not ready for work data normalization labels May 20, 2022
@obulat obulat mentioned this issue May 20, 2022
29 tasks
@obulat obulat transferred this issue from WordPress/openverse-frontend Feb 22, 2023
@obulat obulat added the 🧱 stack: frontend Related to the Nuxt frontend label Feb 22, 2023
dhruvkb pushed a commit that referenced this issue Apr 14, 2023
Use constants and create DAG objects at top level
@dhruvkb dhruvkb added this to the Data normalization milestone Dec 2, 2023
@krysal
Copy link
Member

krysal commented Feb 20, 2024

The frontend already uses the value from the API:

const metadata = computed<null | Metadata[]>(() => {
if (!props.media) {
return null
}
return getMediaMetadata(props.media, i18n, {
width: props.imageWidth,
height: props.imageHeight,
type: props.imageType,
})
})

const getImageType = (
imageType: string | undefined,
i18n: NuxtI18nInstance
) => {
if (imageType) {
if (imageType.split("/").length > 1) {
return imageType.split("/")[1]
}
return imageType
}
return i18n.t("mediaDetails.information.unknown")
}
const getAudioType = (audio: AudioDetail, i18n: NuxtI18nInstance) => {
if (!audio.alt_files) {
return audio.filetype ?? i18n.t("mediaDetails.information.unknown")
}
const altFormats = audio.alt_files
.map((altFile) => altFile.filetype)
.filter((filetype) => filetype !== audio.filetype)
const uniqueFormats = Array.from(new Set(altFormats))
if (audio.filetype) {
uniqueFormats.unshift(audio.filetype)
}
return [...uniqueFormats].join(", ")
}

Closing.

@krysal krysal closed this as completed Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💻 aspect: code Concerns the software code in the repository ✨ goal: improvement Improvement to an existing user-facing feature 🟨 priority: medium Not blocking but should be addressed soon 🧱 stack: frontend Related to the Nuxt frontend ⛔ status: blocked Blocked & therefore, not ready for work
Projects
Archived in project
Development

No branches or pull requests

3 participants