Skip to content

Commit

Permalink
text and image overlays
Browse files Browse the repository at this point in the history
  • Loading branch information
colbyfayock committed Oct 3, 2024
1 parent e33a792 commit 1d81a11
Show file tree
Hide file tree
Showing 2 changed files with 250 additions and 4 deletions.
102 changes: 100 additions & 2 deletions docs/src/content/docs/guides/image-overlays.mdx
Original file line number Diff line number Diff line change
@@ -1,11 +1,109 @@
---
title: Image Overlays
description: Image Overlays
description: Placing images on top of images in Astro with Cloudinary.
head:
- tag: title
content: Image Overlays - Astro Cloudinary
---
import { Tabs, TabItem } from '@astrojs/starlight/components';

import { CldImage } from '../../../../../astro-cloudinary';

import CodeBlock from '../../../components/CodeBlock.astro';
import HeaderImage from '../../../components/HeaderImage.astro';
import HeaderImage from '../../../components/HeaderImage.astro';

With the CldImage component, you can easily place an image onto an existing
image with overlays.

## Example

<HeaderImage>
<CldImage
src="samples/people/kitchen-bar"
width="960"
height="600"
crop="fill"
overlays={[{
publicId: "samples/food/fish-vegetables",
position: {
x: 50,
y: 50,
gravity: 'north_east',
},
effects: [{
crop: 'fill',
width: 350,
height: 350,
gravity: 'auto',
border: '5px_solid_yellow'
}]
}]}
alt="Chef in a kitchen with image overlay"
sizes="50vw"
/>
</HeaderImage>

<Tabs items={['CldImage', 'getCldImageUrl']}>
<TabItem className="nx-pt-0" label="CldImage">
<CodeBlock>
```jsx
import { CldImage } from 'astro-cloudinary';

<CldImage
src="<Public ID>"
width="<Width>"
height="<Height>"
overlays={[{
publicId: "<Public ID>",
position: {
x: 50,
y: 50,
gravity: 'north_east',
},
effects: [{
crop: 'fill',
width: 350,
height: 350,
gravity: 'auto',
border: '5px_solid_yellow'
}]
}]}
alt=""
sizes="100vw"
/>
```
</CodeBlock>
</TabItem>
<TabItem className="nx-pt-0" label="getCldImageUrl">
<CodeBlock>
```jsx
import { getCldImageUrl } from 'astro-cloudinary/helpers';

getCldImageUrl({
width: 1335,
height: 891,
src: '<Public ID>',
overlays: [{
publicId: '<Public ID>',
position: {
x: 50,
y: 50,
gravity: 'north_east',
},
effects: [{
crop: 'fill',
width: 350,
height: 350,
gravity: 'auto',
border: '5px_solid_yellow'
}]
}]
})
```
</CodeBlock>
</TabItem>
</Tabs>

## Learn More
* [CldImage](/cldimage/basic-usage)
* [getCldImageUrl](/getcldimageurl/basic-usage)
152 changes: 150 additions & 2 deletions docs/src/content/docs/guides/text-overlays.mdx
Original file line number Diff line number Diff line change
@@ -1,11 +1,159 @@
---
title: Text Overlays
description: Text Overlays
description: Adding text to images in Astro with Cloudinary.
head:
- tag: title
content: Text Overlays - Astro Cloudinary
---
import { Tabs, TabItem } from '@astrojs/starlight/components';

import { CldImage } from '../../../../../astro-cloudinary';

import CodeBlock from '../../../components/CodeBlock.astro';
import HeaderImage from '../../../components/HeaderImage.astro';
import HeaderImage from '../../../components/HeaderImage.astro';

You can easily add text on top of your image with text-based overlays using
the CldImage component.

## Example

<HeaderImage>
<CldImage
width="1335"
height="891"
src="cld-sample-5"
sizes="100vw"
overlays={[
{
position: {
x: 150,
y: 125,
angle: -20,
gravity: 'south_east',
},
text: {
color: 'magenta',
fontFamily: 'Source Sans Pro',
fontSize: 150,
fontWeight: 'black',
text: 'WITH STYLE'
}
},
{
position: {
x: 140,
y: 140,
angle: -20,
gravity: 'south_east',
},
text: {
color: 'white',
fontFamily: 'Source Sans Pro',
fontSize: 150,
fontWeight: 'black',
text: 'WITH STYLE'
}
},
]}
alt="Sneakers with text With Style"
/>
</HeaderImage>

<Tabs items={['CldImage', 'getCldImageUrl']}>
<TabItem className="nx-pt-0" label="CldImage">
<CodeBlock>
```jsx
import { CldImage } from 'astro-cloudinary';

<CldImage
width="1335"
height="891"
src="images/sneakers"
sizes="100vw"
overlays={[
{
position: {
x: 150,
y: 125,
angle: -20,
gravity: 'south_east',
},
text: {
color: 'magenta',
fontFamily: 'Source Sans Pro',
fontSize: 150,
fontWeight: 'black',
text: 'WITH STYLE'
}
},
{
position: {
x: 140,
y: 140,
angle: -20,
gravity: 'south_east',
},
text: {
color: 'white',
fontFamily: 'Source Sans Pro',
fontSize: 150,
fontWeight: 'black',
text: 'WITH STYLE'
}
},
]}
alt="Sneakers with text With Style"
/>
```
</CodeBlock>
</TabItem>
<TabItem className="nx-pt-0" label="getCldImageUrl">
<CodeBlock>
```jsx
import { getCldImageUrl } from 'astro-cloudinary/helpers';

getCldImageUrl({
width: 1335,
height: 891,
src: 'images/sneakers',
overlays: [
{
position: {
x: 150,
y: 125,
angle: -20,
gravity: 'south_east',
},
text: {
color: 'magenta',
fontFamily: 'Source Sans Pro',
fontSize: 150,
fontWeight: 'black',
text: 'WITH STYLE'
}
},
{
position: {
x: 140,
y: 140,
angle: -20,
gravity: 'south_east',
},
text: {
color: 'white',
fontFamily: 'Source Sans Pro',
fontSize: 150,
fontWeight: 'black',
text: 'WITH STYLE'
}
},
]
})
```
</CodeBlock>
</TabItem>
</Tabs>

## Learn More
* [CldImage](/cldimage/basic-usage)
* [getCldImageUrl](/getcldimageurl/basic-usage)

0 comments on commit 1d81a11

Please sign in to comment.