aboutsummaryrefslogtreecommitdiffstats
path: root/src/services/graphql/helpers/convert-wp-image-to-img.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/services/graphql/helpers/convert-wp-image-to-img.ts')
-rw-r--r--src/services/graphql/helpers/convert-wp-image-to-img.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/services/graphql/helpers/convert-wp-image-to-img.ts b/src/services/graphql/helpers/convert-wp-image-to-img.ts
new file mode 100644
index 0000000..392aaf9
--- /dev/null
+++ b/src/services/graphql/helpers/convert-wp-image-to-img.ts
@@ -0,0 +1,16 @@
+import type { Img, WPImage } from '../../../types';
+
+export const convertWPImgToImg = ({
+ altText,
+ mediaDetails,
+ sourceUrl,
+ title,
+}: WPImage): Img => {
+ return {
+ alt: altText ?? '',
+ height: mediaDetails.height,
+ src: sourceUrl,
+ title: title ?? undefined,
+ width: mediaDetails.width,
+ };
+};