Skip to content

Commit ad93044

Browse files
committed
Add image CDN tutorial
1 parent f485dfa commit ad93044

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

_posts/2019-08-08-write-a-new-post.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,22 +118,44 @@ By default, the image is centered, but you can specify the position by using one
118118
Image will be left aligned in below sample:
119119

120120
```markdown
121-
![Desktop View](/assets/img/sample/mockup.png){: width="350" .normal}
121+
![Desktop View](/assets/img/sample/mockup.png){: .normal}
122122
```
123123

124124
- **Float to the left**
125125

126126
```markdown
127-
![Desktop View](/assets/img/sample/mockup.png){: width="240" .left}
127+
![Desktop View](/assets/img/sample/mockup.png){: .left}
128128
```
129129

130130
- **Float to the right**
131131

132132
```markdown
133-
![Desktop View](/assets/img/sample/mockup.png){: width="240" .right}
133+
![Desktop View](/assets/img/sample/mockup.png){: .right}
134134
```
135135

136-
> **Limitation**: Once you specify the position of an image, it is forbidden to add the image caption.
136+
**Limitation**: Once you specify the position of an image, it is forbidden to add the image caption.
137+
138+
### CDN URL
139+
140+
If you host the images on the CDN, you can save the time of repeatedly writing the CDN url by assigning the variable `img_cdn` of `_config.yml` file:
141+
142+
```yaml
143+
img_cdn: https://cdn.com
144+
```
145+
146+
Once `img_cdn` is assigned, the CDN url will be added to the path of all images (images of site avatar and posts) starting with `/`.
147+
148+
For instance, when using images:
149+
150+
```markdown
151+
![The flower](/path/to/flower.png)
152+
```
153+
154+
The parsing result will automatically add the CDN prefix `https://cdn.com` before the image path:
155+
156+
```html
157+
<img src="https://cdn.com/path/to/flower.png" alt="The flower">
158+
```
137159

138160
## Pinned Posts
139161

0 commit comments

Comments
 (0)