-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e33a792
commit 1d81a11
Showing
2 changed files
with
250 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |