Skip to content

Commit

Permalink
add: background_image setting 背景图片设置
Browse files Browse the repository at this point in the history
number value
  • Loading branch information
MOxFIVE committed Nov 17, 2015
1 parent ded4e97 commit 51645e6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,23 @@ hexo new page tags
#### 3. Background image 网页背景:

Change image list in: 修改背景图地址
Find or change background images in folder | 修改背景图地址:

> `themes/yelee/layout/_partial/background.ejs`
> `/yelee/source/background/`
Remove background image and use white-gray theme by:
Setting in `themes/yelee/_config.yml` 背景参数:

取消网页背景图,使用淳朴的灰白主题
`
background_image: 5
`

> `themes/yelee/_config.yml` - `background_image: false`
- Default value is 5, free to modify the number | 默认值为5,可按需修改

- "5": show 5 images form bg-1.jpg to bg-5.jpg in `/yelee/source/background/`

- "5": 设置`/yelee/source/background/`文件夹中 bg-1.jpg 到 bg-5.jpg 这5张图片为背景

- "0": remove background image and use white-gray theme | 取消网页背景图,使用淳朴的灰白主题

#### 4. Style image 自定义图片样式:
In order to style posts/pages' image with HTML/CSS within `.md` files, you should disable fancybox function firstly.
Expand Down
6 changes: 4 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ subnav:
# Customize feed link 自定义订阅地址
rss: /atom.xml

# true: 个性图片背景, false: 淳朴灰白背景
background_image: true
# "5": show images form bg-1.jpg to bg-5.jpg in `/yelee/source/background/`
# "5": 显示`/yelee/source/background/`文件夹中 bg-1.jpg 到 bg-5.jpg 这5张图片
# "0": white-gray background | 淳朴灰白背景
background_image: 5

# Content
excerpt_link: more
Expand Down
10 changes: 4 additions & 6 deletions layout/_partial/background.ejs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<% if (theme.background_image){ %>
<script type="text/javascript">
var backgroundnum = 10;
<script>
var backgroundnum = <%= theme.background_image %>;
var backgroundimg = "url(/background/bg-x.jpg)".replace(/x/gi, Math.ceil(Math.random() * backgroundnum));
$("body").css({"background": backgroundimg, "background-attachment": "fixed", "background-size": "cover"});
</script>
<% } else { %>
<style type="text/css">
<style>
body {
background: lightgray;
}
Expand All @@ -25,4 +23,4 @@
background-color: #bfd3ec;
}
</style>
<% } %>
<% } %>

0 comments on commit 51645e6

Please sign in to comment.