From fc0b95fc75942c1b9e334a9b918e992a28d834e1 Mon Sep 17 00:00:00 2001
From: mohith2883 <88938356+mohith2883@users.noreply.github.com>
Date: Wed, 1 Oct 2025 19:18:15 +0530
Subject: [PATCH 1/9] docs: migrate guides from v1 to v2 Starlight
---
.../docs/guides/background-removal.mdx | 75 ++++++
.../docs/guides/image-optimization.mdx | 73 ++++++
.../content/docs/guides/image-overlays.mdx | 121 ++++++++++
.../content/docs/guides/image-underlays.mdx | 77 +++++++
.../src/content/docs/guides/placeholders.mdx | 160 +++++++++++++
.../content/docs/guides/responsive-images.mdx | 88 +++++++
.../content/docs/guides/social-media-card.mdx | 216 ++++++++++++++++++
.../src/content/docs/guides/text-overlays.mdx | 131 +++++++++++
.../guides/uploading-images-and-videos.mdx | 54 +++++
vercel.json | 40 ----
10 files changed, 995 insertions(+), 40 deletions(-)
create mode 100644 packages/docs/src/content/docs/guides/background-removal.mdx
create mode 100644 packages/docs/src/content/docs/guides/image-optimization.mdx
create mode 100644 packages/docs/src/content/docs/guides/image-overlays.mdx
create mode 100644 packages/docs/src/content/docs/guides/image-underlays.mdx
create mode 100644 packages/docs/src/content/docs/guides/placeholders.mdx
create mode 100644 packages/docs/src/content/docs/guides/responsive-images.mdx
create mode 100644 packages/docs/src/content/docs/guides/social-media-card.mdx
create mode 100644 packages/docs/src/content/docs/guides/text-overlays.mdx
create mode 100644 packages/docs/src/content/docs/guides/uploading-images-and-videos.mdx
diff --git a/packages/docs/src/content/docs/guides/background-removal.mdx b/packages/docs/src/content/docs/guides/background-removal.mdx
new file mode 100644
index 00000000..0651f44b
--- /dev/null
+++ b/packages/docs/src/content/docs/guides/background-removal.mdx
@@ -0,0 +1,75 @@
+---
+title: Guides/Background Removal
+order: 1
+---
+
+
+
+# Removing a Background from an Image
+
+The CldImage component allows you to easily remove backgrounds from images using the `removeBackground` prop.
+
+
+ Removing backgrounds require enabling the Cloudinary AI Background Removal Add-On which includes a free tier for getting started.
+
+
+## Example
+
+
+
+
+
+
+
+
+```svelte
+
+
+
+```
+
+
+
+
+```html
+
+```
+
+
+
+
+## Learn More
+
+- [CldImage](/cldimage/usage)
+- [getCldImageUrl](/getcldimageurl/usage)
\ No newline at end of file
diff --git a/packages/docs/src/content/docs/guides/image-optimization.mdx b/packages/docs/src/content/docs/guides/image-optimization.mdx
new file mode 100644
index 00000000..e8c341e8
--- /dev/null
+++ b/packages/docs/src/content/docs/guides/image-optimization.mdx
@@ -0,0 +1,73 @@
+---
+title: Guides/Image Optimization
+order: 2
+---
+
+
+
+# Optimizing Images in Svelte/SvelteKit
+
+Automatically optimize images using the CldImage component. By default, CldImage opts you in to automatic optimization including delivering the most optimal format for the browser (WebP, AVIF).
+
+You can further optimize delivery by using [responsive sizing](/guides/responsive-images) by using the `sizes` prop.
+
+## Example
+
+
+
+
+
+
+
+
+```svelte
+
+
+
+```
+
+
+
+
+```svelte
+
+```
+
+
+
+
+## Watch & Learn
+
+
+
+## Learn More
+
+- [Responsive Images](/guides/responsive-images)
+- [CldImage](/cldimage/usage)
+- [getCldImageUrl](/getcldimageurl/usage)
\ No newline at end of file
diff --git a/packages/docs/src/content/docs/guides/image-overlays.mdx b/packages/docs/src/content/docs/guides/image-overlays.mdx
new file mode 100644
index 00000000..2aaf0d51
--- /dev/null
+++ b/packages/docs/src/content/docs/guides/image-overlays.mdx
@@ -0,0 +1,121 @@
+---
+title: Guides/Image Overlays
+order: 3
+---
+
+
+
+# Overlaying Images
+
+You can add images on top of other images by using image-based overlays.
+
+## Example
+
+
+
+
+
+
+
+
+```svelte
+
+
+
+```
+
+
+
+
+```svelte
+
+```
+
+
+
+
+## Learn More
+
+- [CldImage](/cldimage/usage)
+- [getCldImageUrl](/getcldimageurl/usage)
\ No newline at end of file
diff --git a/packages/docs/src/content/docs/guides/image-underlays.mdx b/packages/docs/src/content/docs/guides/image-underlays.mdx
new file mode 100644
index 00000000..4775362a
--- /dev/null
+++ b/packages/docs/src/content/docs/guides/image-underlays.mdx
@@ -0,0 +1,77 @@
+---
+title: Guides/Image Underlays
+order: 4
+---
+
+
+
+# Adding Layers Under Images
+
+Underlays function very similar to overlays in terms of options, however they **do not support text**.
+
+See the examples above under Overlays to learn more about the available configurations.
+
+## Example
+
+
+
+
+
+
+
+
+```svelte
+
+
+
+```
+
+
+
+
+```svelte
+
+```
+
+
+
+
+## Learn More
+
+- [CldImage](/cldimage/usage)
+- [getCldImageUrl](/getcldimageurl/usage)
\ No newline at end of file
diff --git a/packages/docs/src/content/docs/guides/placeholders.mdx b/packages/docs/src/content/docs/guides/placeholders.mdx
new file mode 100644
index 00000000..4b9ea770
--- /dev/null
+++ b/packages/docs/src/content/docs/guides/placeholders.mdx
@@ -0,0 +1,160 @@
+---
+title: Guides/Placeholders
+---
+
+
+
+# Display Placeholder While Image is Loading
+
+CldImage wraps the Unpic Image component, thus giving us access to the placeholder API
+which can display an SVG image while the image itself is loading.
+
+This helps for providing a great user experience, rather than an empty space, to help
+let the visitor know that image is loading.
+
+To do this, we have several options:
+
+- `placeholder="blur"` coupled with a `blurDataURL`
+- `placeholder="..."` with the contents being a data URL
+
+## Blurred Images
+
+To achieve a blurred image effect, we can first convert our Cloudinary image to a Data URL
+then pass it in to our CldImage component.
+
+
+
+
+
+ Inside of the SvelteKit app, we can utilize server side code to generate a data URL from our image.
+
+
+
+```js
+
+import { getCldImageUrl } from 'svelte-cloudinary';
+
+export const load = () => {
+ const imageUrl = getCldImageUrl({
+ src: '',
+ width: 100, // Resize the original file to a smaller size
+ });
+ const response = await fetch(imageUrl);
+ const arrayBuffer = await response.arrayBuffer();
+ const buffer = Buffer.from(arrayBuffer);
+ const base64 = buffer.toString("base64");
+ const dataUrl = `data:${response.type};base64,${base64}`;
+ return {
+ dataUrl
+ }
+}
+```
+
+
+
+ Then when rendering CldImage, utilize the `dataUrl` using `placeholder` and `blurDataURL`:
+
+```svelte
+
+
+
+```
+
+## Shimmer
+
+In a similar fashion, we can create a shimmer effect when
+our images are loading.
+
+
+
+
+
+Inside of the SvelteKit app you can use a server side code `+page.server.js` to generate a data URL from our image.
+
+
+
+```js
+export const load = () => {
+ const shimmer = (w: number, h: number) => `
+ `;
+
+ const toBase64 = (str: string) =>
+ typeof window === 'undefined' ? Buffer.from(str).toString('base64') : window.btoa(str);
+
+ const dataUrl = `data:image/svg+xml;base64,${toBase64(shimmer(600, 400))}`;
+ return {
+ dataUrl
+ };
+};
+```
+
+
+
+ Then when rendering CldImage, utilize the `dataUrl` using `placeholder`:
+
+```svelte
+
+
+
+```
+
+## Learn More
+
+- [CldImage](/cldimage/usage)
+- [getCldImageUrl](/getcldimageurl/usage)
\ No newline at end of file
diff --git a/packages/docs/src/content/docs/guides/responsive-images.mdx b/packages/docs/src/content/docs/guides/responsive-images.mdx
new file mode 100644
index 00000000..0692d9da
--- /dev/null
+++ b/packages/docs/src/content/docs/guides/responsive-images.mdx
@@ -0,0 +1,88 @@
+---
+title: Guides/Responsive Images
+---
+
+
+
+# Responsive Images
+
+The [CldImage](/cldimage/usage) component takes advantage of responsive images generated using the [Unpic component](https://unpic.pics/img/svelte/).
+
+Using the `sizes` prop, you can configure exactly the sizes you need for your application:
+
+```svelte
+
+
+
+ import { CldImage } from 'svelte-cloudinary';
+
+
+
+```
+
+Using cropping, we're setting a width of 600px and a height of 600px, telling Cloudinary we want to take our original image, crop it to that size, then position the focal point to the face in the image detected using AI.
+
+From a responsive standpoint, we're stating that we want full width images on anything less than 480px and half-width images on anything above.
+
+The challenge here is when cropping the image, we're cropping it to 600px, which is smaller than some of the sizes we want to responsively serve. We don't want to responsively change that cropped size, otherwise we would change the cropping results due to the crop attempting to grab different portions of the image depending on the size.
+
+To avoid attempting to load upscaled images, resulting in blurry or grainy images as well as more bandwidth used on a device, any responsive size that is greater than the set width will not be generated and instead, we'll deliver an image at the size specifiy (in this example, 600x600).
+
+For instance, in the above, the resulting responive image in the HTML may look like:
+
+```jsx copy
+
+
+```
+
+Notice that all of the URLs are the same except for the first one, as it's smaller than 600px.
+
+When the browser attempts to load these responsive images, it will effectively ignore the same URLs, only having loaded it once if resizing the browser.
\ No newline at end of file
diff --git a/packages/docs/src/content/docs/guides/social-media-card.mdx b/packages/docs/src/content/docs/guides/social-media-card.mdx
new file mode 100644
index 00000000..1fe3e9e3
--- /dev/null
+++ b/packages/docs/src/content/docs/guides/social-media-card.mdx
@@ -0,0 +1,216 @@
+---
+title: Guides/Social Media Cards
+---
+
+
+
+# Generating Social Media Cards
+
+
+ CldOgImage does not render an `<img>` tag, meaning it can't be visually embedded on a page. The following examples make use of the `<CldImage>` tag to showcase what's possible.
+
+
+## Example
+
+
+
+
+
+
+
+
+```svelte
+
+
+
+```
+
+
+
+
+```svelte
+
+```
+
+
+
+
+## Learn More
+
+- [CldOgImage Configuration](/cldogimage/configuration)
\ No newline at end of file
diff --git a/packages/docs/src/content/docs/guides/text-overlays.mdx b/packages/docs/src/content/docs/guides/text-overlays.mdx
new file mode 100644
index 00000000..e9927dee
--- /dev/null
+++ b/packages/docs/src/content/docs/guides/text-overlays.mdx
@@ -0,0 +1,131 @@
+---
+title: Guides/Text Overlays
+---
+
+
+
+# Adding Text to an Image
+
+You can add text on top of your image with text-based overlays.
+
+## Example
+
+
+
+
+
+
+
+
+```svelte
+
+
+
+```
+
+
+
+
+```svelte
+
+```
+
+
+
+
+## Learn More
+
+- [CldImage](/cldimage/usage)
+- [getCldImageUrl](/getcldimageurl/usage)
\ No newline at end of file
diff --git a/packages/docs/src/content/docs/guides/uploading-images-and-videos.mdx b/packages/docs/src/content/docs/guides/uploading-images-and-videos.mdx
new file mode 100644
index 00000000..97a15f61
--- /dev/null
+++ b/packages/docs/src/content/docs/guides/uploading-images-and-videos.mdx
@@ -0,0 +1,54 @@
+---
+title: Guides/Uploading Images and Videos
+order: 9
+---
+
+
+
+# Uploading Images & Videos
+
+Use the [CldUploadButton](/clduploadbutton/usage) or [CldUploadWidget](/clduploadwidget/usage) components to add upload capabilities to your app.
+
+The components utilize the [Cloudinary Upload Widget](https://cloudinary.com/documentation/upload_widget), built for Svelte.
+
+## Example
+
+ {
+resource = result?.info;
+widget.close();
+}}
+uploadPreset={PUBLIC_CLOUDINARY_UNSIGNED_UPLOAD_PRESET}
+/>
+{#if resource?.resource_type === 'image'}
+
+{/if}
+
+{#if resource?.resource_type === 'video'}
+
+{/if}
+
+```svelte
+
+
+
+ Upload to Cloudinary
+
+```
+
+## Learn More
+
+- [CldUploadButton](/clduploadbutton/usage)
\ No newline at end of file
diff --git a/vercel.json b/vercel.json
index 0ff0df24..7b907c4f 100644
--- a/vercel.json
+++ b/vercel.json
@@ -77,46 +77,6 @@
"source": "/getcldogimageurl/examples",
"destination": "/missing"
},
- {
- "source": "/guides",
- "destination": "/missing"
- },
- {
- "source": "/guides/background-removal",
- "destination": "/missing"
- },
- {
- "source": "/guides/image-optimization",
- "destination": "/missing"
- },
- {
- "source": "/guides/image-overlays",
- "destination": "/missing"
- },
- {
- "source": "/guides/image-underlays",
- "destination": "/missing"
- },
- {
- "source": "/guides/placeholders",
- "destination": "/missing"
- },
- {
- "source": "/guides/responsive-images",
- "destination": "/missing"
- },
- {
- "source": "/guides/social-media-cards",
- "destination": "/missing"
- },
- {
- "source": "/guides/text-overlays",
- "destination": "/missing"
- },
- {
- "source": "/guides/uploading-images-and-videos",
- "destination": "/missing"
- },
{
"source": "/templates",
"destination": "/missing"
From 265f4842aafb7a09ffcc01649fa323decbb5af93 Mon Sep 17 00:00:00 2001
From: mohith2883 <88938356+mohith2883@users.noreply.github.com>
Date: Sun, 5 Oct 2025 07:43:56 +0530
Subject: [PATCH 2/9] docs: migrate guides from v1 to v2 Starlight
---
.../docs/src/content/docs/guides/background-removal.mdx | 8 --------
.../docs/src/content/docs/guides/image-optimization.mdx | 2 ++
packages/docs/src/content/docs/guides/placeholders.mdx | 2 ++
3 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/packages/docs/src/content/docs/guides/background-removal.mdx b/packages/docs/src/content/docs/guides/background-removal.mdx
index 0651f44b..e62fbd48 100644
--- a/packages/docs/src/content/docs/guides/background-removal.mdx
+++ b/packages/docs/src/content/docs/guides/background-removal.mdx
@@ -1,15 +1,7 @@
---
title: Guides/Background Removal
-order: 1
---
-
# Removing a Background from an Image
diff --git a/packages/docs/src/content/docs/guides/image-optimization.mdx b/packages/docs/src/content/docs/guides/image-optimization.mdx
index e8c341e8..bce07c15 100644
--- a/packages/docs/src/content/docs/guides/image-optimization.mdx
+++ b/packages/docs/src/content/docs/guides/image-optimization.mdx
@@ -59,12 +59,14 @@ You can further optimize delivery by using [responsive sizing](/guides/responsiv
+
## Learn More
diff --git a/packages/docs/src/content/docs/guides/placeholders.mdx b/packages/docs/src/content/docs/guides/placeholders.mdx
index 4b9ea770..4b179f54 100644
--- a/packages/docs/src/content/docs/guides/placeholders.mdx
+++ b/packages/docs/src/content/docs/guides/placeholders.mdx
@@ -31,6 +31,7 @@ To do this, we have several options:
To achieve a blurred image effect, we can first convert our Cloudinary image to a Data URL
then pass it in to our CldImage component.
+
Inside of the SvelteKit app, we can utilize server side code to generate a data URL from our image.
From 4aa58a663556c71f4664e331aa073d08cd630a03 Mon Sep 17 00:00:00 2001
From: mohith2883 <88938356+mohith2883@users.noreply.github.com>
Date: Mon, 6 Oct 2025 17:03:15 +0530
Subject: [PATCH 3/9] docs: migrate guides from v1 to v2 Starlight
---
.../docs/src/content/docs/guides/background-removal.mdx | 3 ---
packages/docs/src/content/docs/guides/placeholders.mdx | 8 ++++----
2 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/packages/docs/src/content/docs/guides/background-removal.mdx b/packages/docs/src/content/docs/guides/background-removal.mdx
index e62fbd48..abedd645 100644
--- a/packages/docs/src/content/docs/guides/background-removal.mdx
+++ b/packages/docs/src/content/docs/guides/background-removal.mdx
@@ -24,9 +24,6 @@ The CldImage component allows you to easily remove backgrounds from images using
/>
-
-
-
```svelte
```
-
-
```html
+ alt="Turtle" />
```
+
-```html
-
-```
+
-
-
+```ts {5}
+import { getCldImageUrl } from 'svelte-cloudinary';
-## Learn More
+const url = getCldImageUrl({
+ src: 'images/turtle',
+ removeBackground: true,
+ width: 960,
+ height: 600,
+});
+```
-- [CldImage](/cldimage/usage)
-- [getCldImageUrl](/getcldimageurl/usage)
\ No newline at end of file
+
+
diff --git a/packages/docs/src/content/docs/guides/image-optimization.mdx b/packages/docs/src/content/docs/guides/image-optimization.mdx
deleted file mode 100644
index 35a41ba5..00000000
--- a/packages/docs/src/content/docs/guides/image-optimization.mdx
+++ /dev/null
@@ -1,74 +0,0 @@
----
-title: Guides/Image Optimization
----
-
-
-
-# Optimizing Images in Svelte/SvelteKit
-
-Automatically optimize images using the CldImage component. By default, CldImage opts you in to automatic optimization including delivering the most optimal format for the browser (WebP, AVIF).
-
-You can further optimize delivery by using [responsive sizing](/guides/responsive-images) by using the `sizes` prop.
-
-## Example
-
-
-
-
-
-
-
-
-```svelte
-
-
-
-```
-
-
-
-
-```svelte
-
-```
-
-
-
-
-
-
-## Learn More
-
-- [Responsive Images](/guides/responsive-images)
-- [CldImage](/cldimage/usage)
-- [getCldImageUrl](/getcldimageurl/usage)
\ No newline at end of file
diff --git a/packages/docs/src/content/docs/guides/image-overlays.mdx b/packages/docs/src/content/docs/guides/image-overlays.mdx
index b0387493..db3ca38a 100644
--- a/packages/docs/src/content/docs/guides/image-overlays.mdx
+++ b/packages/docs/src/content/docs/guides/image-overlays.mdx
@@ -1,15 +1,9 @@
---
-title: Guides/Image Overlays
+title: Image Overlays
---
-
+import { Tabs, TabItem } from '@astrojs/starlight/components';
+import { CldOgImage, CldImage } from 'svelte-cloudinary';
# Overlaying Images
@@ -17,36 +11,36 @@ You can add images on top of other images by using image-based overlays.
## Example
-
-
-
+
-
-
+
+
-```svelte
+```svelte {11-27}
@@ -56,65 +50,58 @@ You can add images on top of other images by using image-based overlays.
height="600"
src="images/turtle"
sizes="100vw"
+ alt="Turtle with earth"
overlays={[
{
publicId: 'images/earth',
position: {
x: 50,
y: 50,
- gravity: 'north_west'
+ gravity: 'north_west',
},
effects: [
{
crop: 'fill',
gravity: 'auto',
width: 500,
- height: 500
- }
- ]
- }
- ]}
- alt="Turtle with earth"
-/>
+ height: 500,
+ },
+ ],
+ },
+ ]} />
```
-
-
+
-```svelte
-
+ ],
+ },
+ ],
+});
```
-
+
-
-## Learn More
-
-- [CldImage](/cldimage/usage)
-- [getCldImageUrl](/getcldimageurl/usage)
\ No newline at end of file
diff --git a/packages/docs/src/content/docs/guides/image-underlays.mdx b/packages/docs/src/content/docs/guides/image-underlays.mdx
index 445b2dfb..70caed99 100644
--- a/packages/docs/src/content/docs/guides/image-underlays.mdx
+++ b/packages/docs/src/content/docs/guides/image-underlays.mdx
@@ -1,15 +1,9 @@
---
-title: Guides/Image Underlays
+title: Image Underlays
---
-
+import { Tabs, TabItem } from '@astrojs/starlight/components';
+import { CldOgImage, CldImage } from 'svelte-cloudinary';
# Adding Layers Under Images
@@ -19,22 +13,20 @@ See the examples above under Overlays to learn more about the available configur
## Example
-
-
-
+
-
-
+
+
-```svelte
+```svelte {10-11}
@@ -46,31 +38,24 @@ See the examples above under Overlays to learn more about the available configur
sizes="100vw"
removeBackground
underlay="images/galaxy"
- alt="Turtle swimming in a galaxy"
-/>
+ alt="Turtle swimming in a galaxy" />
```
-
-
+
-```svelte
-
+```ts {7-8}
+import { getCldImageUrl } from 'svelte-cloudinary';
+
+const url = getCldImageUrl({
+ width: 960,
+ height: 600,
+ src: 'images/turtle',
+ removeBackground: true,
+ underlay: 'images/galaxy',
+});
```
-
+
-
-## Learn More
-
-- [CldImage](/cldimage/usage)
-- [getCldImageUrl](/getcldimageurl/usage)
\ No newline at end of file
diff --git a/packages/docs/src/content/docs/guides/placeholders.mdx b/packages/docs/src/content/docs/guides/placeholders.mdx
deleted file mode 100644
index 06aa8727..00000000
--- a/packages/docs/src/content/docs/guides/placeholders.mdx
+++ /dev/null
@@ -1,162 +0,0 @@
----
-title: Guides/Placeholders
----
-
-
-
-# Display Placeholder While Image is Loading
-
-CldImage wraps the Unpic Image component, thus giving us access to the placeholder API
-which can display an SVG image while the image itself is loading.
-
-This helps for providing a great user experience, rather than an empty space, to help
-let the visitor know that image is loading.
-
-To do this, we have several options:
-
-- `placeholder="blur"` coupled with a `blurDataURL`
-- `placeholder="..."` with the contents being a data URL
-
-## Blurred Images
-
-To achieve a blurred image effect, we can first convert our Cloudinary image to a Data URL
-then pass it in to our CldImage component.
-
-
-
- Inside of the SvelteKit app, we can utilize server side code to generate a data URL from our image.
-
-
-
-```js
-
-import { getCldImageUrl } from 'svelte-cloudinary';
-
-export const load = () => {
- const imageUrl = getCldImageUrl({
- src: '',
- width: 100, // Resize the original file to a smaller size
- });
- const response = await fetch(imageUrl);
- const arrayBuffer = await response.arrayBuffer();
- const buffer = Buffer.from(arrayBuffer);
- const base64 = buffer.toString("base64");
- const dataUrl = `data:${response.type};base64,${base64}`;
- return {
- dataUrl
- }
-}
-```
-
-
-
- Then when rendering CldImage, utilize the `dataUrl` using `placeholder` and `blurDataURL`:
-
-```svelte
-
-
-
-```
-
-## Shimmer
-
-In a similar fashion, we can create a shimmer effect when
-our images are loading.
-
-
-
-
-
-Inside of the SvelteKit app you can use a server side code `+page.server.js` to generate a data URL from our image.
-
-
-
-```js
-export const load = () => {
- const shimmer = (w: number, h: number) => `
- `;
-
- const toBase64 = (str: string) =>
- typeof window === 'undefined' ? Buffer.from(str).toString('base64') : window.btoa(str);
-
- const dataUrl = `data:image/svg+xml;base64,${toBase64(shimmer(600, 400))}`;
- return {
- dataUrl
- };
-};
-```
-
-
-
- Then when rendering CldImage, utilize the `dataUrl` using `placeholder`:
-
-```svelte
-
-
-
-```
-
-## Learn More
-
-- [CldImage](/cldimage/usage)
-- [getCldImageUrl](/getcldimageurl/usage)
\ No newline at end of file
diff --git a/packages/docs/src/content/docs/guides/responsive-images.mdx b/packages/docs/src/content/docs/guides/responsive-images.mdx
index 0692d9da..3274a15b 100644
--- a/packages/docs/src/content/docs/guides/responsive-images.mdx
+++ b/packages/docs/src/content/docs/guides/responsive-images.mdx
@@ -1,34 +1,22 @@
---
-title: Guides/Responsive Images
+title: Responsive Images
---
-
+import { CldOgImage, CldImage } from 'svelte-cloudinary';
-# Responsive Images
-
-The [CldImage](/cldimage/usage) component takes advantage of responsive images generated using the [Unpic component](https://unpic.pics/img/svelte/).
+The CldImage component takes advantage of responsive images generated using the Unpic component.
Using the `sizes` prop, you can configure exactly the sizes you need for your application:
```svelte
```
Which would give you roughly full width images on mobile, a 2-column layout on tablets, and 3-column layout on desktop views.
@@ -52,8 +40,7 @@ In an example such as:
height="600"
sizes="(max-width: 480px) 100vw, 50vw"
crop="thumb"
- gravity="faces"
-/>
+ gravity="faces" />
```
Using cropping, we're setting a width of 600px and a height of 600px, telling Cloudinary we want to take our original image, crop it to that size, then position the focal point to the face in the image detected using AI.
@@ -67,7 +54,6 @@ To avoid attempting to load upscaled images, resulting in blurry or grainy image
For instance, in the above, the resulting responive image in the HTML may look like:
```jsx copy
-
-
-
+
-
-
+
+
-```svelte
+```svelte {6}
+ gravity: 'west',
+ },
+ },
+ ]} />
```
-
-
+
-```svelte
-
+ position: {
+ x: 100,
+ y: -100,
+ gravity: 'west',
+ },
+ },
+ {
+ width: 1400,
+ crop: 'fit',
+ text: {
+ color: 'black',
+ fontFamily: 'Source Sans Pro',
+ fontSize: 80,
+ text: 'Get the power of Cloudinary in a Svelte project with Svelte Cloudinary!',
+ },
+ position: {
+ x: 100,
+ y: 100,
+ gravity: 'west',
+ },
+ },
+ ],
+});
```
-
+
-
-## Learn More
-
-- [CldOgImage Configuration](/cldogimage/configuration)
\ No newline at end of file
diff --git a/packages/docs/src/content/docs/guides/text-overlays.mdx b/packages/docs/src/content/docs/guides/text-overlays.mdx
index e9927dee..c3114a12 100644
--- a/packages/docs/src/content/docs/guides/text-overlays.mdx
+++ b/packages/docs/src/content/docs/guides/text-overlays.mdx
@@ -1,57 +1,48 @@
---
-title: Guides/Text Overlays
+title: Text Overlays
---
-
-
-# Adding Text to an Image
+import { Tabs, TabItem } from '@astrojs/starlight/components';
+import { CldOgImage, CldImage } from 'svelte-cloudinary';
You can add text on top of your image with text-based overlays.
## Example
-
-
-
+ alt="Sneakers with Cool Beans"
+ overlays={[
+ {
+ width: 2670 - 20,
+ crop: 'fit',
+ position: {
+ x: 140,
+ y: 140,
+ angle: -20,
+ gravity: 'south_east',
+ },
+ text: {
+ color: 'blueviolet',
+ fontFamily: 'Source Sans Pro',
+ fontSize: 160,
+ fontWeight: 'bold',
+ textDecoration: 'underline',
+ letterSpacing: 14,
+ text: 'Cool Beans',
+ },
+ },
+ ]}
-
-
+/>
+
+
+
-```svelte
+```svelte {11-30}
@@ -61,6 +52,7 @@ You can add text on top of your image with text-based overlays.
height="891"
src="images/sneakers"
sizes="100vw"
+ alt="Sneakers with Cool Beans"
overlays={[
{
width: 2670 - 20,
@@ -69,7 +61,7 @@ You can add text on top of your image with text-based overlays.
x: 140,
y: 140,
angle: -20,
- gravity: 'south_east'
+ gravity: 'south_east',
},
text: {
color: 'blueviolet',
@@ -78,54 +70,46 @@ You can add text on top of your image with text-based overlays.
fontWeight: 'bold',
textDecoration: 'underline',
letterSpacing: 14,
- text: 'Cool Beans'
- }
- }
- ]}
- alt="Sneakers with Cool Beans"
-/>
+ text: 'Cool Beans',
+ },
+ },
+ ]} />
```
-
-
+
-```svelte
-
+```ts {7-27}
+import { getCldImageUrl } from 'svelte-cloudinary';
+
+const url = getCldImageUrl({
+ width: 1335,
+ height: 891,
+ src: 'images/sneakers',
+ overlays: [
+ {
+ width: 2670 - 20,
+ crop: 'fit',
+ position: {
+ x: 140,
+ y: 140,
+ angle: -20,
+ gravity: 'south_east',
+ },
+ text: {
+ color: 'blueviolet',
+ fontFamily: 'Source Sans Pro',
+ fontSize: 160,
+ fontWeight: 'bold',
+ textDecoration: 'underline',
+ letterSpacing: 14,
+ text: 'Cool Beans',
+ },
+ },
+ ],
+});
```
-
+
-
-## Learn More
-
-- [CldImage](/cldimage/usage)
-- [getCldImageUrl](/getcldimageurl/usage)
\ No newline at end of file
diff --git a/packages/docs/src/content/docs/guides/uploading-images-and-videos.mdx b/packages/docs/src/content/docs/guides/uploading-images-and-videos.mdx
deleted file mode 100644
index 1ed5e5aa..00000000
--- a/packages/docs/src/content/docs/guides/uploading-images-and-videos.mdx
+++ /dev/null
@@ -1,53 +0,0 @@
----
-title: Guides/Uploading Images and Videos
----
-
-
-
-# Uploading Images & Videos
-
-Use the [CldUploadButton](/clduploadbutton/usage) or [CldUploadWidget](/clduploadwidget/usage) components to add upload capabilities to your app.
-
-The components utilize the [Cloudinary Upload Widget](https://cloudinary.com/documentation/upload_widget), built for Svelte.
-
-## Example
-
- {
-resource = result?.info;
-widget.close();
-}}
-uploadPreset={PUBLIC_CLOUDINARY_UNSIGNED_UPLOAD_PRESET}
-/>
-{#if resource?.resource_type === 'image'}
-
-{/if}
-
-{#if resource?.resource_type === 'video'}
-
-{/if}
-
-```svelte
-
-
-
- Upload to Cloudinary
-
-```
-
-## Learn More
-
-- [CldUploadButton](/clduploadbutton/usage)
\ No newline at end of file
From 24147f2270ebb6cabb0e6f03f034cd6b2bfe077f Mon Sep 17 00:00:00 2001
From: "Willow (GHOST)"
Date: Wed, 4 Mar 2026 06:36:46 +0000
Subject: [PATCH 6/9] chore: get rest of guides running
---
packages/docs/astro.config.mjs | 1 +
.../src/content/docs/guides/placeholders.mdx | 131 ++++++++++++++++++
.../guides/uploading-images-and-videos.mdx | 19 +++
packages/docs/src/lib/examples/Upload.svelte | 33 +++++
4 files changed, 184 insertions(+)
create mode 100644 packages/docs/src/content/docs/guides/placeholders.mdx
create mode 100644 packages/docs/src/content/docs/guides/uploading-images-and-videos.mdx
create mode 100644 packages/docs/src/lib/examples/Upload.svelte
diff --git a/packages/docs/astro.config.mjs b/packages/docs/astro.config.mjs
index eaaf9a61..f64edea9 100644
--- a/packages/docs/astro.config.mjs
+++ b/packages/docs/astro.config.mjs
@@ -177,6 +177,7 @@ export default defineConfig({
optimizeDeps: {
exclude: ['svelte-cloudinary'],
},
+ envPrefix: ['PUBLIC', 'VITE'],
plugins: [
{
// https://github.com/sveltejs/svelte/issues/9288#issuecomment-1748034687
diff --git a/packages/docs/src/content/docs/guides/placeholders.mdx b/packages/docs/src/content/docs/guides/placeholders.mdx
new file mode 100644
index 00000000..1ea82e96
--- /dev/null
+++ b/packages/docs/src/content/docs/guides/placeholders.mdx
@@ -0,0 +1,131 @@
+---
+title: Placeholders
+---
+
+import { Tabs, TabItem } from '@astrojs/starlight/components';
+import { CldOgImage, CldImage } from 'svelte-cloudinary';
+
+CldImage wraps the Unpic Image component, thus giving us access to the placeholder API
+which can display an SVG image while the image itself is loading.
+
+This helps for providing a great user experience, rather than an empty space, to help
+let the visitor know that image is loading.
+
+To do this, we have several options:
+
+- `placeholder="blur"` coupled with a `blurDataURL`
+- `placeholder="..."` with the contents being a data URL
+
+## Blurred Images
+
+To achieve a blurred image effect, we can first convert our Cloudinary image to a Data URL
+then pass it in to our CldImage component.
+
+
+
+Inside of the SvelteKit app, we can utilize server side code to generate a data URL from our image.
+
+```js
+
+import { getCldImageUrl } from 'svelte-cloudinary';
+
+export const load = () => {
+ const imageUrl = getCldImageUrl({
+ src: '',
+ width: 100, // Resize the original file to a smaller size
+ });
+ const response = await fetch(imageUrl);
+ const arrayBuffer = await response.arrayBuffer();
+ const buffer = Buffer.from(arrayBuffer);
+ const base64 = buffer.toString("base64");
+ const dataUrl = `data:${response.type};base64,${base64}`;
+ return {
+ dataUrl
+ }
+}
+```
+
+Then when rendering CldImage, utilize the `dataUrl` using `placeholder` and `blurDataURL`:
+
+```svelte
+
+
+
+```
+
+## Shimmer
+
+In a similar fashion, we can create a shimmer effect when
+our images are loading.
+
+
+
+Inside of the SvelteKit app you can use a server side code `+page.server.js` to generate a data URL from our image.
+
+```js
+export const load = () => {
+ const shimmer = (w: number, h: number) => `
+ `;
+
+ const toBase64 = (str: string) =>
+ typeof window === 'undefined' ? Buffer.from(str).toString('base64') : window.btoa(str);
+
+ const dataUrl = `data:image/svg+xml;base64,${toBase64(shimmer(600, 400))}`;
+ return {
+ dataUrl
+ };
+};
+```
+
+Then when rendering CldImage, utilize the `dataUrl` using `placeholder`:
+
+```svelte
+
+
+
+```
diff --git a/packages/docs/src/content/docs/guides/uploading-images-and-videos.mdx b/packages/docs/src/content/docs/guides/uploading-images-and-videos.mdx
new file mode 100644
index 00000000..7af54054
--- /dev/null
+++ b/packages/docs/src/content/docs/guides/uploading-images-and-videos.mdx
@@ -0,0 +1,19 @@
+---
+title: Uploading Images and Videos
+---
+
+import uploadCode from '$lib/examples/Upload.svelte?raw';
+import { Code } from '@astrojs/starlight/components';
+import Upload from '$lib/examples/Upload.svelte';
+
+# Uploading Images & Videos
+
+Use the [CldUploadButton](/clduploadbutton/usage) or [CldUploadWidget](/clduploadwidget/usage) components to add upload capabilities to your app.
+
+The components utilize the [Cloudinary Upload Widget](https://cloudinary.com/documentation/upload_widget), built for Svelte.
+
+## Example
+
+
+
+
diff --git a/packages/docs/src/lib/examples/Upload.svelte b/packages/docs/src/lib/examples/Upload.svelte
new file mode 100644
index 00000000..c4f79422
--- /dev/null
+++ b/packages/docs/src/lib/examples/Upload.svelte
@@ -0,0 +1,33 @@
+
+
+ {
+ if (typeof result.info === 'object') {
+ info = result.info;
+ widget.close();
+ }
+ }} />
+
+{#if info?.resource_type === 'video'}
+
+{:else if info}
+
+{:else}
+
Try uploading something!
+{/if}
From bd529c5aaa8965fd3fcdb2769eb8603161fab67f Mon Sep 17 00:00:00 2001
From: "Willow (GHOST)"
Date: Wed, 4 Mar 2026 06:52:16 +0000
Subject: [PATCH 7/9] chore: update redirects
---
vercel.json | 40 ----------------------------------------
1 file changed, 40 deletions(-)
diff --git a/vercel.json b/vercel.json
index 7172e2cc..aec43f6a 100644
--- a/vercel.json
+++ b/vercel.json
@@ -77,46 +77,6 @@
"source": "/getcldogimageurl/examples",
"destination": "/missing"
},
- {
- "source": "/guides",
- "destination": "/missing"
- },
- {
- "source": "/guides/background-removal",
- "destination": "/missing"
- },
- {
- "source": "/guides/image-optimization",
- "destination": "/missing"
- },
- {
- "source": "/guides/image-overlays",
- "destination": "/missing"
- },
- {
- "source": "/guides/image-underlays",
- "destination": "/missing"
- },
- {
- "source": "/guides/placeholders",
- "destination": "/missing"
- },
- {
- "source": "/guides/responsive-images",
- "destination": "/missing"
- },
- {
- "source": "/guides/social-media-cards",
- "destination": "/missing"
- },
- {
- "source": "/guides/text-overlays",
- "destination": "/missing"
- },
- {
- "source": "/guides/uploading-images-and-videos",
- "destination": "/missing"
- },
{
"source": "/templates",
"destination": "/missing"
From 23cc806cc4b24ed29bf2977b595f614add5a46d5 Mon Sep 17 00:00:00 2001
From: "Willow (GHOST)"
Date: Wed, 4 Mar 2026 06:52:51 +0000
Subject: [PATCH 8/9] fix: file name
---
.../docs/guides/{social-media-card.mdx => social-media-cards.mdx} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename packages/docs/src/content/docs/guides/{social-media-card.mdx => social-media-cards.mdx} (100%)
diff --git a/packages/docs/src/content/docs/guides/social-media-card.mdx b/packages/docs/src/content/docs/guides/social-media-cards.mdx
similarity index 100%
rename from packages/docs/src/content/docs/guides/social-media-card.mdx
rename to packages/docs/src/content/docs/guides/social-media-cards.mdx
From a6dd86d68711d067c1d086862c12c54727eb2b6e Mon Sep 17 00:00:00 2001
From: "Willow (GHOST)"
Date: Wed, 4 Mar 2026 07:26:40 +0000
Subject: [PATCH 9/9] docs: update content
---
.../docs/guides/background-removal.mdx | 21 ++-
.../content/docs/guides/image-overlays.mdx | 107 --------------
.../content/docs/guides/image-underlays.mdx | 17 +--
.../{text-overlays.mdx => overlays.mdx} | 96 +++++++++----
.../src/content/docs/guides/placeholders.mdx | 131 ------------------
.../content/docs/guides/responsive-images.mdx | 71 +++-------
.../docs/guides/social-media-cards.mdx | 94 ++++++-------
.../guides/uploading-images-and-videos.mdx | 13 +-
packages/docs/src/lib/examples/Upload.svelte | 18 +--
vercel.json | 8 ++
10 files changed, 171 insertions(+), 405 deletions(-)
delete mode 100644 packages/docs/src/content/docs/guides/image-overlays.mdx
rename packages/docs/src/content/docs/guides/{text-overlays.mdx => overlays.mdx} (52%)
delete mode 100644 packages/docs/src/content/docs/guides/placeholders.mdx
diff --git a/packages/docs/src/content/docs/guides/background-removal.mdx b/packages/docs/src/content/docs/guides/background-removal.mdx
index fe9c6757..a7cbb457 100644
--- a/packages/docs/src/content/docs/guides/background-removal.mdx
+++ b/packages/docs/src/content/docs/guides/background-removal.mdx
@@ -1,27 +1,23 @@
---
title: Background Removal
+description: Learn how to use Cloudinary to remove a background from your image.
---
import { Tabs, TabItem } from '@astrojs/starlight/components';
import { CldImage } from 'svelte-cloudinary';
-# Removing a Background from an Image
-
-The CldImage component allows you to easily remove backgrounds from images using the `removeBackground` prop.
-
:::note
-Removing backgrounds require enabling the [Cloudinary AI Background Removal Add-On](https://cloudinary.com/documentation/cloudinary_ai_background_removal_addon) - a free tier is available!
+The Cloudinary AI Background Removal add-on is required to use this feature.
:::
-## Example
+You can use the `removeBackground` option to generatively remove the background from an image, for example:
@@ -36,9 +32,8 @@ Removing backgrounds require enabling the [Cloudinary AI Background Removal Add-
width="960"
height="600"
src="images/turtle"
- sizes="100vw"
- removeBackground
- alt="Turtle" />
+ alt="turtle image"
+ removeBackground />
```
diff --git a/packages/docs/src/content/docs/guides/image-overlays.mdx b/packages/docs/src/content/docs/guides/image-overlays.mdx
deleted file mode 100644
index db3ca38a..00000000
--- a/packages/docs/src/content/docs/guides/image-overlays.mdx
+++ /dev/null
@@ -1,107 +0,0 @@
----
-title: Image Overlays
----
-
-import { Tabs, TabItem } from '@astrojs/starlight/components';
-import { CldOgImage, CldImage } from 'svelte-cloudinary';
-
-# Overlaying Images
-
-You can add images on top of other images by using image-based overlays.
-
-## Example
-
-
-
-
-
-
-```svelte {11-27}
-
-
-
-```
-
-
-
-
-
-```ts {7-24}
-import { getCldImageUrl } from 'svelte-cloudinary';
-
-const url = getCldImageUrl({
- width: 960,
- height: 600,
- src: 'images/turtle',
- overlays: [
- {
- publicId: 'images/earth',
- position: {
- x: 50,
- y: 50,
- gravity: 'north_west',
- },
- effects: [
- {
- crop: 'fill',
- gravity: 'auto',
- width: 500,
- height: 500,
- },
- ],
- },
- ],
-});
-```
-
-
-
diff --git a/packages/docs/src/content/docs/guides/image-underlays.mdx b/packages/docs/src/content/docs/guides/image-underlays.mdx
index 70caed99..d971e332 100644
--- a/packages/docs/src/content/docs/guides/image-underlays.mdx
+++ b/packages/docs/src/content/docs/guides/image-underlays.mdx
@@ -1,32 +1,27 @@
---
title: Image Underlays
+description: Learn how to use Cloudinary to programatically place images under images.
---
import { Tabs, TabItem } from '@astrojs/starlight/components';
import { CldOgImage, CldImage } from 'svelte-cloudinary';
-# Adding Layers Under Images
-
-Underlays function very similar to overlays in terms of options, however they **do not support text**.
-
-See the examples above under Overlays to learn more about the available configurations.
-
-## Example
+An image underlay allows you to place one image under another (it doesn't work with text). For example we can remove the background from this turtle image, then underlay an image of space:
-```svelte {10-11}
+```svelte {11-12}
@@ -36,9 +31,9 @@ See the examples above under Overlays to learn more about the available configur
height="600"
src="images/turtle"
sizes="100vw"
+ alt="Turtle swimming in a galaxy"
removeBackground
- underlay="images/galaxy"
- alt="Turtle swimming in a galaxy" />
+ underlay="images/galaxy" />
```
diff --git a/packages/docs/src/content/docs/guides/text-overlays.mdx b/packages/docs/src/content/docs/guides/overlays.mdx
similarity index 52%
rename from packages/docs/src/content/docs/guides/text-overlays.mdx
rename to packages/docs/src/content/docs/guides/overlays.mdx
index c3114a12..1772cbc1 100644
--- a/packages/docs/src/content/docs/guides/text-overlays.mdx
+++ b/packages/docs/src/content/docs/guides/overlays.mdx
@@ -1,21 +1,36 @@
---
-title: Text Overlays
+title: Overlays
+description: Learn how to use Cloudinary to programatically place images/text on top of other images/text.
---
import { Tabs, TabItem } from '@astrojs/starlight/components';
import { CldOgImage, CldImage } from 'svelte-cloudinary';
-You can add text on top of your image with text-based overlays.
-
-## Example
+You can use the overlays feature to stack images or text on top of each other, for example:
-```svelte {11-30}
+```svelte {11-47}
@@ -80,14 +110,30 @@ You can add text on top of your image with text-based overlays.
-```ts {7-27}
+```ts {7-43}
import { getCldImageUrl } from 'svelte-cloudinary';
const url = getCldImageUrl({
- width: 1335,
- height: 891,
- src: 'images/sneakers',
+ width: 960,
+ height: 600,
+ src: 'images/turtle',
overlays: [
+ {
+ publicId: 'images/earth',
+ position: {
+ x: 50,
+ y: 50,
+ gravity: 'north_west',
+ },
+ effects: [
+ {
+ crop: 'fill',
+ gravity: 'auto',
+ width: 500,
+ height: 500,
+ },
+ ],
+ },
{
width: 2670 - 20,
crop: 'fit',
@@ -100,11 +146,11 @@ const url = getCldImageUrl({
text: {
color: 'blueviolet',
fontFamily: 'Source Sans Pro',
- fontSize: 160,
+ fontSize: 80,
fontWeight: 'bold',
textDecoration: 'underline',
letterSpacing: 14,
- text: 'Cool Beans',
+ text: 'Svelte x Cloudinary',
},
},
],
diff --git a/packages/docs/src/content/docs/guides/placeholders.mdx b/packages/docs/src/content/docs/guides/placeholders.mdx
deleted file mode 100644
index 1ea82e96..00000000
--- a/packages/docs/src/content/docs/guides/placeholders.mdx
+++ /dev/null
@@ -1,131 +0,0 @@
----
-title: Placeholders
----
-
-import { Tabs, TabItem } from '@astrojs/starlight/components';
-import { CldOgImage, CldImage } from 'svelte-cloudinary';
-
-CldImage wraps the Unpic Image component, thus giving us access to the placeholder API
-which can display an SVG image while the image itself is loading.
-
-This helps for providing a great user experience, rather than an empty space, to help
-let the visitor know that image is loading.
-
-To do this, we have several options:
-
-- `placeholder="blur"` coupled with a `blurDataURL`
-- `placeholder="..."` with the contents being a data URL
-
-## Blurred Images
-
-To achieve a blurred image effect, we can first convert our Cloudinary image to a Data URL
-then pass it in to our CldImage component.
-
-
-
-Inside of the SvelteKit app, we can utilize server side code to generate a data URL from our image.
-
-```js
-
-import { getCldImageUrl } from 'svelte-cloudinary';
-
-export const load = () => {
- const imageUrl = getCldImageUrl({
- src: '',
- width: 100, // Resize the original file to a smaller size
- });
- const response = await fetch(imageUrl);
- const arrayBuffer = await response.arrayBuffer();
- const buffer = Buffer.from(arrayBuffer);
- const base64 = buffer.toString("base64");
- const dataUrl = `data:${response.type};base64,${base64}`;
- return {
- dataUrl
- }
-}
-```
-
-Then when rendering CldImage, utilize the `dataUrl` using `placeholder` and `blurDataURL`:
-
-```svelte
-
-
-
-```
-
-## Shimmer
-
-In a similar fashion, we can create a shimmer effect when
-our images are loading.
-
-
-
-Inside of the SvelteKit app you can use a server side code `+page.server.js` to generate a data URL from our image.
-
-```js
-export const load = () => {
- const shimmer = (w: number, h: number) => `
- `;
-
- const toBase64 = (str: string) =>
- typeof window === 'undefined' ? Buffer.from(str).toString('base64') : window.btoa(str);
-
- const dataUrl = `data:image/svg+xml;base64,${toBase64(shimmer(600, 400))}`;
- return {
- dataUrl
- };
-};
-```
-
-Then when rendering CldImage, utilize the `dataUrl` using `placeholder`:
-
-```svelte
-
-
-
-```
diff --git a/packages/docs/src/content/docs/guides/responsive-images.mdx b/packages/docs/src/content/docs/guides/responsive-images.mdx
index 3274a15b..5cc667e6 100644
--- a/packages/docs/src/content/docs/guides/responsive-images.mdx
+++ b/packages/docs/src/content/docs/guides/responsive-images.mdx
@@ -1,33 +1,23 @@
---
title: Responsive Images
+description: Learn how to use Cloudinary to generate performant responsive images.
---
import { CldOgImage, CldImage } from 'svelte-cloudinary';
-The CldImage component takes advantage of responsive images generated using the Unpic component.
+Responsive images are great for performance since the browser can load a smaller image on a smaller device, where the drop in quality isn't noticable. This will increase page load times and general user experience for everyone, as they get both a noticably high quality image and faster page load.
-Using the `sizes` prop, you can configure exactly the sizes you need for your application:
-
-```svelte
-
+You can configure specifically the image sizes you want, using a media query like synax, with the `sizes` prop/option. Cloudinary will generate the necessary sizes on the fly, as usual!
-```
-
-Which would give you roughly full width images on mobile, a 2-column layout on tablets, and 3-column layout on desktop views.
-
-To ensure that the responsive images can effectively determine all appropriate sizes for the images, use the actual image width and height when specifying the dimension props.
-
-### Responsive Images & CldImage
-
-The only caveat to this is when using cropping modes in Cloudinary.
-
-In an example such as:
+ (max-width: 1200px) 50vw,
+ 33vw"
+ alt="turtle image"
+/>
```svelte
-```
-
-Using cropping, we're setting a width of 600px and a height of 600px, telling Cloudinary we want to take our original image, crop it to that size, then position the focal point to the face in the image detected using AI.
-
-From a responsive standpoint, we're stating that we want full width images on anything less than 480px and half-width images on anything above.
-
-The challenge here is when cropping the image, we're cropping it to 600px, which is smaller than some of the sizes we want to responsively serve. We don't want to responsively change that cropped size, otherwise we would change the cropping results due to the crop attempting to grab different portions of the image depending on the size.
-
-To avoid attempting to load upscaled images, resulting in blurry or grainy images as well as more bandwidth used on a device, any responsive size that is greater than the set width will not be generated and instead, we'll deliver an image at the size specifiy (in this example, 600x600).
-
-For instance, in the above, the resulting responive image in the HTML may look like:
-
-```jsx copy
-
+ src="images/turtle"
+ sizes="(max-width: 768px) 100vw,
+ (max-width: 1200px) 50vw,
+ 33vw"
+ alt="turtle image" />
```
-
-Notice that all of the URLs are the same except for the first one, as it's smaller than 600px.
-
-When the browser attempts to load these responsive images, it will effectively ignore the same URLs, only having loaded it once if resizing the browser.
diff --git a/packages/docs/src/content/docs/guides/social-media-cards.mdx b/packages/docs/src/content/docs/guides/social-media-cards.mdx
index 2c7e6cf6..6e0d4d61 100644
--- a/packages/docs/src/content/docs/guides/social-media-cards.mdx
+++ b/packages/docs/src/content/docs/guides/social-media-cards.mdx
@@ -1,18 +1,15 @@
---
title: Social Media Cards
+description: Learn how to use Cloudinary to generate dynamic social media cards.
---
import { Tabs, TabItem } from '@astrojs/starlight/components';
import { CldOgImage, CldImage } from 'svelte-cloudinary';
:::note
-CldOgImage does not render an `` tag, meaning it can't be
-visually embedded on a page. The following examples make use of the
-`` tag to showcase what's possible.
+CldOgImage does not render an `` tag, meaning it can't be visually embedded on a page. The following examples make use of the `` tag to showcase what's possible.
:::
-## Example
-
-```svelte {6}
+```svelte {9-58}
@@ -86,7 +84,7 @@ visually embedded on a page. The following examples make use of the
alt="Svelte Cloudinary with picture of a mountain"
overlays={[
{
- publicId: 'images/mountain',
+ publicId: `images/mountain`,
position: {
x: 0,
y: 0,
@@ -96,39 +94,40 @@ visually embedded on a page. The following examples make use of the
{
crop: 'fill',
gravity: 'auto',
- width: 800,
- height: 1200,
+ width: '0.33',
+ height: '1.0',
},
],
+ flags: ['relative'],
},
{
- width: 1400,
+ width: 700,
crop: 'fit',
text: {
color: 'black',
fontFamily: 'Source Sans Pro',
- fontSize: 160,
+ fontSize: 80,
fontWeight: 'bold',
- text: 'Svelte Cloudinary',
+ text: 'Next Cloudinary',
},
position: {
- x: 100,
- y: -100,
+ x: 80,
+ y: -50,
gravity: 'west',
},
},
{
- width: 1400,
+ width: 700,
crop: 'fit',
text: {
color: 'black',
fontFamily: 'Source Sans Pro',
- fontSize: 80,
- text: 'Get the power of Cloudinary in a Svelte project with Svelte Cloudinary!',
+ fontSize: 40,
+ text: 'Get the power of Cloudinary in a Next.js project with Next Cloudinary!',
},
position: {
- x: 100,
- y: 100,
+ x: 80,
+ y: 50,
gravity: 'west',
},
},
@@ -139,7 +138,7 @@ visually embedded on a page. The following examples make use of the
-```ts {3}
+```ts {6-55}
import { getCldOgImageUrl } from 'svelte-cloudinary';
// You're responsible for adding the correct meta tags
@@ -147,7 +146,7 @@ const url = getCldOgImageUrl({
src: 'images/white',
overlays: [
{
- publicId: 'images/mountain',
+ publicId: `images/mountain`,
position: {
x: 0,
y: 0,
@@ -157,39 +156,40 @@ const url = getCldOgImageUrl({
{
crop: 'fill',
gravity: 'auto',
- width: 800,
- height: 1200,
+ width: '0.33',
+ height: '1.0',
},
],
+ flags: ['relative'],
},
{
- width: 1400,
+ width: 700,
crop: 'fit',
text: {
color: 'black',
fontFamily: 'Source Sans Pro',
- fontSize: 160,
+ fontSize: 80,
fontWeight: 'bold',
- text: 'Svelte Cloudinary',
+ text: 'Next Cloudinary',
},
position: {
- x: 100,
- y: -100,
+ x: 80,
+ y: -50,
gravity: 'west',
},
},
{
- width: 1400,
+ width: 700,
crop: 'fit',
text: {
color: 'black',
fontFamily: 'Source Sans Pro',
- fontSize: 80,
- text: 'Get the power of Cloudinary in a Svelte project with Svelte Cloudinary!',
+ fontSize: 40,
+ text: 'Get the power of Cloudinary in a Next.js project with Next Cloudinary!',
},
position: {
- x: 100,
- y: 100,
+ x: 80,
+ y: 50,
gravity: 'west',
},
},
diff --git a/packages/docs/src/content/docs/guides/uploading-images-and-videos.mdx b/packages/docs/src/content/docs/guides/uploading-images-and-videos.mdx
index 7af54054..39ee3178 100644
--- a/packages/docs/src/content/docs/guides/uploading-images-and-videos.mdx
+++ b/packages/docs/src/content/docs/guides/uploading-images-and-videos.mdx
@@ -1,19 +1,18 @@
---
title: Uploading Images and Videos
+description: Learn how to use Cloudinary to enable users to upload images and/or videos.
---
import uploadCode from '$lib/examples/Upload.svelte?raw';
import { Code } from '@astrojs/starlight/components';
import Upload from '$lib/examples/Upload.svelte';
-# Uploading Images & Videos
+You can use the upload widget, or as a shortcut the upload button, to enable the users to upload images and/or videos.
-Use the [CldUploadButton](/clduploadbutton/usage) or [CldUploadWidget](/clduploadwidget/usage) components to add upload capabilities to your app.
-
-The components utilize the [Cloudinary Upload Widget](https://cloudinary.com/documentation/upload_widget), built for Svelte.
-
-## Example
+:::caution
+Starlight (the documentation framework we use) messes with the upload widget, we're working on a fix but it'll work fine with your Svelte/SvelteKit websites!
+:::
-
+
diff --git a/packages/docs/src/lib/examples/Upload.svelte b/packages/docs/src/lib/examples/Upload.svelte
index c4f79422..cb4555b3 100644
--- a/packages/docs/src/lib/examples/Upload.svelte
+++ b/packages/docs/src/lib/examples/Upload.svelte
@@ -9,14 +9,6 @@
let info = $state(null);
- {
- if (typeof result.info === 'object') {
- info = result.info;
- widget.close();
- }
- }} />
-
{#if info?.resource_type === 'video'}
{:else}
-
Try uploading something!
+
Click the button below to try uploading something: