My Hexo example link: https://yuan901202.github.io/gallery/
Function list
Main interface
- Category album
- Custom album name
- Custom cover
- Automatically cut the cover to the same size
Classified album interface
- Third-order
- Tiled by image original aspect ratio
- Local picture source / picture bed outer chain
- Uniform with the article illustration format
- Click for larger image
Other
Preparation
The contents of this section are based on the notes on the premise of the local save image function. If you use the outer link of the map, you can skip all the steps involving the
img
folder and theimg/s
folder.All functions of this album are only tested under the effect of
hexo-theme-next
. When using other themes, some layout size data may be biased, and you need to modify it according to the theme settings.
▶ Create a directory
Enter the command
hexo new page gallery
in git bash;Create the classified album folder you need in the
hexo/sourse/gallery` directory;
Go to the
hexo/sourse/gallery
directory and create a newimg
folder to store the album cover.Create an
img
folder in each album folder to store large images, and animg/s
folder to store thumbnails.
Note: img/s
folder can be omitted, and the thumbnail can be renamed in the format of the file name-s.jpg
.
▶ Image processing
Original image processing:
Put the image you want to upload into the
gallery/album_name/img
folder. In order to load the speed, it is recommended to compress it to less than 1mb and save it in jpg format.There are no requirements other than file size, but to facilitate subsequent page editing, it is recommended to rename the file in an easily identifiable way, such as
date-picture_name.jpg
.
Thumbnail processing:
Copy all the images under
gallery/album_name/img
to thegallery/album_name/img/s
folder and compress the image size using other processing tools such as PS;The recommended width is 300px, and the final output file size is around 30kb, and the height is not required.
Cover photo processing:
Select the desired cover from the thumbnail of each album and copy it to the
gallery/img
folder.It is recommended to rename it to the
album_name.jpg
.
▶ Album main interface
Open
gallery/index.md
and set thetitle
to the name of the album page you need;(Option) Turn comments on by including
comments: false
below the date;Copy the following code into the body and modify the
album description
,album name
,album folder name
, andcover image file name
as needed:
1 | <center>!相册描述【此行可删除】</center> |
Note:
When you need to use the outer chain, replace the contents of
<img src="img/[cover image file name].jpg">
with the outer address of the map bed;The
<div class="gallery-column">
element in the code displays the number of columns in the album in separate columns, which can be increased or decreased as needed;When adding a new album, please make sure the code is added inside the
<div class="gallery-column">
element, otherwise it will cause a display error.
▶ Classified album interface
Open
gallery/album_name/index.md
and set title to the name of the album page you need;(Option) Turn comments on by including
comments: false
below the date;Copy the following code into the body and modify the
album description
,image name
, andthumbnail file name
as needed:
1 | <center>!相册描述【此行可删除】</center> |
Note:
If you need to use the outer chain, replace the content in
<img src="img/[picture name].jpg">
with the outer address of the map bed. If the map is loaded fast enough, you can use the same link. Fill in the thumbnail portion;The
<div class="img-column">
element in the code displays the number of columns in the column, which can be increased or decreased as needed;When adding a picture, please make sure the code is added inside the
<div class="img-column">
element, otherwise it will cause a display error.
▶ CSS stylesheet
Add the following code to custom.styl
:
1 | /*gallery*/ |
Note:
The style in the
@media
tag is to prevent the album name from being forced to wrap when browsing on the mobile terminal. It is recommended to keep it;The rest of the styles can be changed as needed, except for the flex related lines and the
object-fit
style, and will not be described here.