
wordpress创建
Are you looking to create an image gallery in WordPress?
您是否要在WordPress中创建图片库?
An image gallery lets you add photos in rows and columns. This allows you to display more photos in less space while also making it easier for users to browse them.
图片库可让您按行和列添加照片。 这样一来,您可以在更小的空间中显示更多照片,同时也使用户更容易浏览它们。
In this article, we will show you how to easily create an image gallery in WordPress that makes your photos look even better.
在本文中,我们将向您展示如何轻松地在WordPress中创建图片库,使您的照片看起来更好。

为什么要在WordPress中创建图片库? (Why Create an Image Gallery in WordPress?)
WordPress makes it super easy to add an image to your blog posts and pages. You just need to add the image block and upload your image.
WordPress使添加图像到您的博客文章和页面变得非常容易。 您只需要添加图像块并上传图像。
However, if you are adding multiple images, then all those images will appear one after another. It doesn’t look great, and your users will have to scroll a lot to view them all.
但是,如果要添加多张图像,则所有这些图像都会一个接一个地显示。 看起来不太好,您的用户将不得不滚动很多才能查看全部内容。

By creating a gallery, you can display images in a grid layout with columns and rows. You can show thumbnails for your pictures, and users can click on them to see the full image.
通过创建图库,您可以按具有列和行的网格布局显示图像。 您可以显示图片的缩略图,用户可以单击它们以查看完整图像。
This way, you will be able to show more photos in less space, and it will look a lot more professional.
这样,您将可以在更小的空间中显示更多照片,而且看起来会更加专业。

WordPress actually comes with a built-in gallery feature for quickly creating photo galleries. The new WordPress block editor includes a Gallery block to let you make a WordPress gallery in just a few clicks.
WordPress实际上具有内置的画廊功能,可快速创建照片画廊。 新的WordPress区块编辑器包含一个Gallery区块,让您只需单击几下即可制作WordPress画廊。
You can also use WordPress image gallery plugins to create even more robust galleries with more features.
您还可以使用WordPress图片库插件创建功能更强大的画廊。
In this tutorial, we will show you both methods to make a photo gallery in WordPress.
在本教程中,我们将向您展示在WordPress中制作相册的两种方法。
Let’s start with the default WordPress gallery block.
让我们从默认的WordPress Gallery块开始。
影片教学 (Video Tutorial)
If you don’t like the video or need more instructions, then continue reading.
如果您不喜欢该视频或需要更多说明,请继续阅读。
方法1。创建没有插件的图像库 (Method 1. Create an Image Gallery without a Plugin)
WordPress comes with a built-in feature that lets you create a gallery. This feature is very basic and does not have many options, but it gets the job done.
WordPress带有内置功能,可让您创建画廊。 此功能非常基础,没有很多选择,但可以完成工作。
Here is how you would create an image gallery in WordPress without using a plugin.
这是您无需使用插件即可在WordPress中创建图片库的方法。
First, you need to edit the post or page where you want to add the image gallery. On the post edit screen, click on the Add New Block icon and select the Gallery block.
首先,您需要编辑要在其中添加图片库的帖子或页面。 在帖子编辑屏幕上,单击“添加新块”图标,然后选择“图库”块。

This will add the Gallery block to your WordPress editor where you can click on the ‘Upload’ button to upload photos from your computer. You can also select from previously uploaded photos in the media library.
这会将Gallery块添加到您的WordPress编辑器中,您可以在其中单击“上传”按钮以从计算机上传照片。 您还可以从媒体库中以前上传的照片中进行选择。

If you click on the Upload button, then you can generally upload one photo at a time. However, you can select and open multiple images with Ctrl key pressed on your keyboard.
如果单击“上传”按钮,则通常一次只能上传一张照片。 但是,您可以在键盘上按Ctrl键选择并打开多个图像。

After you have uploaded all the images, you can add captions to your images. Simply click on the photos, and you will see ‘Write caption…’ option where you need to enter the caption.
上传完所有图像后,可以为图像添加标题。 只需单击照片,您将在需要输入标题的地方看到“写标题...”选项。

If you select the Media Library button, then you will be able to choose images for your gallery all at once. As you select images, you can also enter the image alt text, title, and caption from the attachment details panel on the right side.
如果选择“媒体库”按钮,则可以一次选择图库的图像。 选择图像时,还可以从右侧的附件详细信息面板输入图像的替代文本,标题和标题。

Select the images you want to add and click on the ‘Create a new gallery’ button at the bottom right corner.
选择要添加的图像,然后单击右下角的“创建新画廊”按钮。
Next, you will see ‘Edit Gallery’ page where you can add/review your image captions. Once done, click on the ‘Update Gallery’ button at the bottom right corner.
接下来,您将看到“编辑库”页面,您可以在其中添加/查看图像标题。 完成后,单击右下角的“更新库”按钮。

After that, your post edit screen will open with the gallery block settings panel on the right side. Now, you can choose the number of columns for each row, enable or disable the Crop images option, and choose where to link your gallery images.
之后,您的帖子编辑屏幕将打开,右侧的图库块设置面板将打开。 现在,您可以选择每行的列数,启用或禁用“裁剪图像”选项,并选择链接图库图像的位置。

From the Link to options, you can choose None if you want your users to only view your photo. This option disables clicking feature for your images.
如果希望用户仅查看照片,则可以从“链接到”选项中选择“无”。 此选项禁用图像的单击功能。
If you select the Media File option, then the images will be clickable, and the image file will open when clicked. Similarly, the attachment page will open if you select the Attachment Page option.
如果选择“媒体文件”选项,则图像将是可单击的,单击时图像文件将打开。 同样,如果选择“附件页面”选项,则将打开附件页面。
Once you are satisfied with the settings, you can publish the post and preview the gallery on your live website.
对设置满意后,您可以发布帖子并在实时网站上预览图库。
For example, here is how the image gallery appeared on our demo website.
例如,以下是图片库在我们的演示网站上的显示方式。

Wasn’t that quick and easy?
那不是那么容易快捷吗?
It looks pretty too. However, if you create image galleries regularly, then you will soon notice that it lacks certain essential features.
看起来也不错。 但是,如果您定期创建图像画廊,那么您很快就会注意到它缺乏某些基本功能。
For example, your images will either be not clickable or open in a new page. If you link your gallery images to the media file or attachment page, then the users will have to click on the back button to view the gallery again.
例如,您的图像将无法单击或在新页面中打开。 如果将图库图像链接到媒体文件或附件页面,则用户将必须单击“后退”按钮再次查看图库。
It is not user-friendly, and your gallery’s appearance depends on your theme. In most cases, you get just one very generic style.
它不是用户友好的,并且画廊的外观取决于您的主题。 在大多数情况下,您只会得到一种非常通用的样式。
You can’t organize your galleries into topics, albums, tags, etc. Your gallery is not stored anywhere and if you needed to add the same gallery again, then you’ll have to recreate it.
您无法将画廊组织成主题,专辑,标签等。画廊不会存储在任何地方,如果您需要再次添加同一画廊,则必须重新创建它。
If you want to add more professional looking image galleries on your site, then you should use the next method.
如果要在网站上添加更具专业外观的图像库,则应使用下一种方法。
方法2。使用Envira Gallery创建一个图像库 (Method 2. Create an Image Gallery Using Envira Gallery)
For this method, we will be using the Envira Gallery plugin. It is the best WordPress image gallery plugin in the market.
对于这种方法,我们将使用Envira Gallery插件。 它是市场上最好的WordPress图像库插件。
Envira allows you to easily create fully-responsive, beautiful, and modern image galleries in WordPress. It is super fast and comes with many features like lightbox popup, easy image navigation, drag and drop builder, and professional gallery templates.
Envira可让您轻松地在WordPress中创建完全响应,美观,现代的图像库。 它速度超快,并具有许多功能,例如灯箱弹出窗口 ,轻松的图像导航,拖放生成器以及专业的画廊模板。
Let’s get started.
让我们开始吧。
First thing you need to do is install and activate the Envira Gallery plugin. For more details, see our step by step guide on how to install a WordPress plugin.
您需要做的第一件事是安装并激活Envira Gallery插件。 有关更多详细信息,请参阅有关如何安装WordPress插件的分步指南。
Upon activation, you need to visit the Envira Gallery » Settings page to enter your license key. You can get this key from your account on the Envira Gallery website.
激活后,您需要访问Envira Gallery»设置页面以输入许可证密钥。 您可以从Envira Gallery网站上的帐户中获取此密钥。

After verifying your license key, you can head over to Envira Gallery » Add New page to create your first gallery.
确认许可证密钥后,您可以转到Envira Gallery»添加新页面来创建您的第一个画廊。

First, you need to provide a title for your gallery and then click on ‘Select files from computer’ button to upload your images.
首先,您需要为图库提供一个标题,然后单击“从计算机中选择文件”按钮以上传图像。
You can also select files from your WordPress media library by clicking on ‘Select files from other sources’ button.
您还可以通过单击“选择其他来源的文件”按钮从WordPress媒体库中选择文件。
Once you upload the images, they will appear in the Gallery section.
上传图像后,它们将出现在“图库”部分中。

You can click the pencil icon on an image to add caption, title, and alt text for each image.
您可以单击图像上的铅笔图标为每个图像添加标题,标题和替代文本。

Next, you need to click on the ‘Configuration’ tab.
接下来,您需要单击“配置”选项卡。
From here you can change your gallery settings like the number of columns, image lazy loading, title and caption positioning, margins, heights, thumbnail sizes, image dimensions, etc.
在这里,您可以更改图库设置,例如列数,图像延迟加载,标题和标题位置,边距,高度,缩略图尺寸,图像尺寸等。

After that, you need to click on the ‘Lightbox’ tab.
之后,您需要点击“灯箱”标签。
The lightbox popup allows users to enlarge images and browse them without ever leaving the page.
灯箱弹出窗口允许用户放大图像并浏览它们而无需离开页面。
The default settings will work very well for most websites, but you can review the options and change them if you like.
默认设置在大多数网站上都可以很好地工作,但是您可以查看这些选项并根据需要更改它们。

Next, you can click on the ‘Mobile’ tab to configure your gallery settings for mobile devices. It allows you to choose image dimensions for mobile devices, enable or disable lightbox, and more.
接下来,您可以点击“移动”标签,为移动设备配置图片库设置。 它使您可以选择移动设备的图像尺寸,启用或禁用灯箱等等。

After that, you can review more options like gallery slug and add custom CSS from the ‘Misc’ section.
之后,您可以查看更多选项,例如Gallery Slug,并从“其他”部分添加自定义CSS。
You can now publish your gallery which will make it available to be added anywhere on your WordPress site.
现在,您可以发布自己的画廊,从而可以将其添加到WordPress网站上的任何位置。
Next, you need to edit a post or page where you want to display your gallery.
接下来,您需要编辑要显示图库的帖子或页面。
On the post edit screen, click on the Add New Block icon and select the Envira Gallery block.
在帖子编辑屏幕上,单击“添加新块”图标,然后选择“ Envira Gallery”块。

Clicking on it will add the Envira Gallery block in the post editor. Now you can search a gallery by its name or find it by clicking on the dropdown arrow icon.
单击它会在帖子编辑器中添加Envira Gallery块。 现在,您可以按名称搜索画廊,也可以通过单击下拉箭头图标找到它。

After that, the plugin will load your gallery in the post editor.
之后,该插件将在帖子编辑器中加载您的画廊。

Next, you can review your gallery settings one more time from the block settings panel on the right side.
接下来,您可以从右侧的块设置面板再次查看图库设置。

You can now save your post and preview it to see the gallery on your live website.
现在,您可以保存您的帖子并对其进行预览,以在实时网站上查看图库。

Clicking on any image in the gallery will open it in the lightbox popup. You can browse images in the lightbox by pressing the left and right arrow keys on the screen or on your keyboard.
点击图库中的任何图片都会在灯箱弹出窗口中将其打开。 您可以通过按屏幕或键盘上的向左和向右箭头键来浏览灯箱中的图像。

Your gallery will look equally great on mobile as well. Users will be able to tap on an image to enlarge it and swipe to view the next or previous image.
您的画廊在移动设备上也将同样出色。 用户将可以点击图像以将其放大并滑动以查看下一个或上一个图像。

We hope this article helped you learn how to create an image gallery in WordPress. You may also want to see our guide on how to fix common image issues in WordPress.
我们希望本文能帮助您学习如何在WordPress中创建图片库。 您可能还希望查看有关如何解决WordPress中常见图像问题的指南。
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在Twitter和Facebook上找到我们。
翻译自: https://www.wpbeginner.com/beginners-guide/how-to-create-an-image-gallery-in-wordpress/
wordpress创建