/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/media-utils/src/utils/transform-attachment.ts
21 строка
692 B
Marco Ciampini
ESLint: Replace strict config with bulk suppressions (#81248)
07 авг 2026, 14:34
Не верифицирован
07 авг 2026, 14:34
7f43eaf
Код
Авторство
О чём код?
import type { Attachment, RestAttachment } from './types'; /** * Transforms an attachment object from the REST API shape into the shape expected by the block editor and other consumers. * * @param attachment REST API attachment object. */ export function transformAttachment( attachment: RestAttachment ): Attachment { // eslint-disable-next-line camelcase const { alt_text, source_url, ...savedMediaProps } = attachment; return { ...savedMediaProps, alt: attachment.alt_text, caption: attachment.caption?.raw ?? '', title: attachment.title.raw, url: attachment.source_url, poster: attachment._embedded?.[ 'wp:featuredmedia' ]?.[ 0 ]?.source_url || undefined, }; }