Skip to content

Commit

Permalink
fix: use webp for twitter og image
Browse files Browse the repository at this point in the history
Closes #127
  • Loading branch information
ghostdevv committed Sep 15, 2024
1 parent 1e51904 commit f47e3f3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
13 changes: 9 additions & 4 deletions packages/svelte-cloudinary/src/components/CldOgImage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,23 @@
...options
} = $$props as CldOgImageProps);
$: url = getCldOgImageUrl(options, config);
$: image = getCldOgImageUrl(options, config);
$: twitterImage = getCldOgImageUrl(
{ ...options, format: options.format ?? 'webp' },
config,
);
</script>

<svelte:head>
<meta property="og:image" content={url} />
<meta property="og:image:secure_url" content={url} />
<meta property="og:image" content={image} />
<meta property="og:image:secure_url" content={image} />
<meta property="og:image:width" content={width.toString()} />
<meta property="og:image:height" content={height.toString()} />
<meta property="og:image:alt" content={alt} />
{#if !excludeTags?.includes('twitter:title')}
<meta property="twitter:title" content={twitterTitle || ' '} />
{/if}
<meta property="twitter:card" content="summary_large_image" />
<meta property="twitter:image" content={url} />
<meta property="twitter:image" content={twitterImage} />
</svelte:head>
6 changes: 3 additions & 3 deletions packages/svelte-cloudinary/src/helpers/getCldOgImageUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export function getCldOgImageUrl(
return getCldImageUrl(
{
...options,
format: options.format || 'jpg',
width: options.width || 1200,
height: options.height || 627,
format: options.format ?? 'jpg',
width: options.width ?? 1200,
height: options.height ?? 627,
},
configOverride,
analyticsOverride,
Expand Down

0 comments on commit f47e3f3

Please sign in to comment.