How to create a photo gallery for your website with these effective methods
The visual design plays a key role in the success of a website, making graphics and images essential elements. One popular method for organizing multiple images on a site is by using galleries. There are several ways to embed image collections: users can, for instance, add a simple lightbox through the source code or use CMS extensions.
How to embed a lightbox photo gallery
A lightbox is one of the simplest methods to display images on a website. It is implemented using dynamic HTML in JavaScript. When users click on thumbnails, the image opens in a larger format, overlaying the website with a dimmed background. This type of lightbox can be easily integrated into your website and enhanced with additional features, making it an excellent choice for modern web development.
The prerequisites are a current version of lightbox and, of course, the images including thumbnails (preview images), that you want to embed in your site. The first lightbox was developed by Lokesh Dhakar in 2005, and he later released the script under a Creative Commons license. There are now numerous versions and iterations of the popular script, which include standalone scripts, plugins for JavaScript libraries, or extensions for content management systems.
- Intuitive website builder with AI assistance
- Create captivating images and texts in seconds
- Domain, SSL and email included
1. Download lightbox
The most well-known lightbox script is available for free download on Lokesh Dhakar’s website. After unpacking the .zip file, you can find the following elements among others: the index.html file in the examples folder, which provides an example, and in the dist directory, the three folders css, images, and js.
2. Embed CSS and JavaScript file
Next, copy the lightbox.css file from the CSS folder into the website’s CSS directory, and the .js file into the JavaScript directory. You will find both of these files in the respective folders within the dist directory. Additionally, you must include the following line in the head of the relevant webpage to load the CSS stylesheet:
<link href="your-css-directory/lightbox.css" rel="stylesheet">htmlAnd the following line must be inserted as the last line before the closing </body> tag to embed the necessary JavaScript:
<script src="your-js-directory/lightbox.js"></script>htmlLightbox depends on jQuery. If it hasn’t been added yet, jQuery must be included and loaded before using the lightbox script.
3. Embed lightbox attributes for photo gallery in HTML
Each image you want to display with the lightbox requires a suitable HTML attribute in the source code to provide the script with the necessary information. Each link to the image must include the data-lightbox attribute with a unique name for each gallery. Images that are part of the same slideshow should all have the same data-lightbox attribute. To add a caption, use the data-title attribute with the appropriate text.
Embedding a single image example
<a href="images/image-1.jpg" data-lightbox="bild-1" data-title="image title">
<img src="images/image-1-preview.jpg" alt="alternative description">
</a>htmlSlideshow with multiple images example
<a href="images/image-2.jpg" data-lightbox="show-1" data-title="morning"><img src="images/image-2-preview.jpg" alt="alternative description"></a>
<a href="images/bild-3.jpg" data-lightbox="show-1" data-title="noon"><img src="images/image-3-preview.jpg" alt="alternative description"></a>
<a href="images/bild-4.jpg" data-lightbox="show-1" data-title="evening"><img src="images/image-4-preview.jpg" alt="alternative description"></a>html4. Customize lightbox
The lightbox is now integrated into the website. Of course, there are other ways to customize the slideshow or lightbox display. Customization is achieved by using the option method after the script is loaded and specifying the desired values. The function appears as follows:
<script src="your-js-directory/lightbox.js"></script>
<script>
lightbox.option({
'resizeDuration': 200,
'wrapAround': true
});
</script>htmlOverview of the most important options
There are various attributes you can use to adjust the behavior of the lightbox within the option function. Here are the most important ones:
| Option | Default | Description |
|---|---|---|
alwaysShowNavOnTouchDevices
|
false
|
When this option is set to true, the navigation arrows, which otherwise only appear when hovered over with a mouse, remain permanently visible on devices with touch screens.
|
disableScrolling
|
false
|
When set to true, scrolling within the page is no longer possible when the lightbox is open.
|
fadeDuration
|
500
|
This option determines how long the overlay takes to fade in or out (time specified in milliseconds). |
maxWidth
|
This option sets the maximum image width (specified in pixels). | |
maxHeight
|
This option sets the maximum image height (specified in pixels). | |
positionFromTop
|
50
|
This option sets the distance from the top edge of the viewport (specified in pixels). |
resizeDuration
|
700
|
This setting determines the time the container needs for the transition between two differently sized images (time specified in milliseconds). |
showImageNumberLabel
|
true
|
If switched to false, the total number of images within the slideshow will no longer be displayed (e.g., Image 3 of 33).
|
wrapAround
|
false
|
If the option is set to true, the slideshow will start again from the beginning after the last image.
|
Alternatively, there are numerous other programs that can be used to create a custom photo gallery for a website and embed it into your own site. These tools are generally very simple and intuitive to use, often featuring a drag-and-drop editor.
How to implement photo galleries directly in HTML and CSS
Photo galleries can also be implemented without JavaScript or a lightbox directly with HTML and CSS. The images are usually arranged in a flexible layout (Grid or Flexbox) that automatically adapts to different screen sizes. This simple solution is especially suitable for fast loading times, responsive designs, and websites that deliberately avoid external scripts.
With just a few lines of CSS, you can create an attractive and organized photo gallery for a website that is both efficient and SEO-friendly. Here’s an example of a simple photo gallery:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple photo gallery</title>
<style>
body {
margin: 0;
padding: 2rem;
background-color: #f9f9f9;
}
h2 {
text-align: center;
margin-bottom: 1.5rem;
}
.gallery {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 10px;
}
.gallery img {
width: 100%;
height: auto;
border-radius: 8px;
transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.gallery img:hover {
transform: scale(1.03);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
</style>
</head>
<body>
<h2>My photo gallery</h2>
<div class="gallery">
<img src="images/image-1.jpg" alt="Sunrise over the ocean">
<img src="images/image-2.jpg" alt="Blooming meadow in spring">
<img src="images/image-3.jpg" alt="Mountain landscape at sunset">
<img src="images/image-4.jpg" alt="City skyline at night">
<img src="images/image-5.jpg" alt="Fall forest trail">
</div>
</body>
</html>htmlIn the HTML section of our simple example, an h2 heading and a div container are defined, within which several images are added using the img tag. Each image includes an alt attribute with a brief description. This is crucial for accessibility and SEO. In the CSS section, the grid layout (display: grid) ensures the images are automatically arranged in columns that adapt to the screen size. The gap: 10px adds spacing between the images. Hover effects, such as enlargement and shadow, enhance the gallery’s interactivity and modern feel when the mouse hovers over an image.
You can easily expand the photo gallery for your website, for example, by adding captions under the photos, applying uniform borders, or using object-fit: cover to display image sections evenly and harmoniously. Additionally, you can adjust the layout with a few CSS modifications to match your corporate design. This way, even without JavaScript, you create a visually appealing, user-friendly, and SEO-optimized photo gallery that can be flexibly embedded into any website.
Photo gallery extensions for content management systems
When implementing their website, many companies and freelancers choose to use a content management system. This has the advantage of providing a “ready-made framework”—most systems also allow the creation of a professional website without deep programming and IT knowledge.
In addition to intuitive operation and user-friendly interfaces, many also appreciate the flexible structure of systems like Joomla! or Typo3. Thanks to their often-modular design, the framework can be expanded and customized to suit individual needs. This is partly due to the large community behind many (open-source) systems, which develops a wide range of extensions and plugins. As a result, there are numerous ways to create and integrate professional photo galleries. We present a few solutions for the systems Joomla!, WordPress, and TYPO3.
Photo galleries for WordPress
WordPress is the most widely used open-source CMS globally. Although originally designed as a blogging platform, WordPress now offers numerous ways to extend and customize, making it a fully-fledged content management system suitable for other purposes as well. Especially in industries like fashion, lifestyle, or beauty, an aesthetic graphic presentation is crucial. It’s no surprise, then, that among the over 60,000 extensions, there are plenty of plugins available for photo galleries.
NextGen Gallery
NextGen Gallery is one of the most well-known plugins for WordPress. Both thumbnail galleries and slideshows are possible with NextGen, and there is also an integrated lightbox option—all in responsive design. The plugin offers many options for very large galleries and simplifies both uploading large numbers of images and image management with its clear structure and ease of use. Key parameters like size, number, or interval are selectable, and adding watermarks is easy to do. In general, NextGen excels with usability and a clearly structured user interface. The free version of NextGen Gallery is available for download from the WordPress plugin collection. On the developers’ website, you can also find the paid versions, which offer additional features for professional use. These versions provide some interesting functions, especially for the e-commerce sector.
Envira Gallery (Lite)
The Envira Gallery plugin also allows users to create photo galleries for their website. Users can create individual galleries for specific posts or pages, as well as global galleries.
The responsive design is available out-of-the-box with Envira and is implemented both for galleries and lightboxes. What sets Envira apart is its asynchronous image loading, ensuring that even with large photo galleries, you don’t have to compromise on loading time and performance. As a photo gallery plugin, Envira also offers advantages from an SEO perspective, as load speed is an important ranking factor.
The free version of Envira Gallery Lite can be downloaded from the WordPress Plugin Directory. Paid versions offer additional features such as watermarks or video galleries. Learn more about these options on the Envira Gallery website.
MetaSlider
The WordPress plugin MetaSlider is also among the most popular solutions for presenting images and slideshows on a website. With its intuitive drag-and-drop interface, users can create sliders in just a few minutes without any programming knowledge. Users can choose from multiple slider types, allowing them to customize the style, animations, and transition effects individually.
A key advantage of MetaSlider is its fully responsive design. All sliders automatically adjust to the screen size, ensuring optimal display of images and text on desktops, smartphones, and tablets. The plugin also offers a variety of SEO options. Additionally, MetaSlider is compatible with the WordPress Block Editor (Gutenberg) and popular page builders, making it easy to integrate into existing layouts. The free version of MetaSlider is available in the official WordPress Plugin Directory. For more features, users can upgrade to the Pro version, which includes video sliders and thumbnail navigation.
Photo galleries for Joomla!
Even Joomla! is gaining increasing popularity, both in the United States and internationally. It is consistently ranked among the most widely used content management systems. Joomla! also provides users with a vast community and a large selection of extensions and plugins.
sigplus
The Simple Image Gallery Plus—abbreviated as sigplus—essentially delivers what its name promises, supporting users in creating simple photo galleries. This lightweight plugin for photo galleries serves its purpose well and is particularly suitable for small websites and galleries with a manageable number of images. Inexperienced users benefit from its ease of use and intuitive operation. In “Advanced Mode,” experienced users can access additional settings for thumbnails, caching, and more. The plugin is free and available for download in the Joomla! Extensions Directory.
Phoca Gallery
Phoca Gallery is also free and offers a significantly broader range of functions compared to the previously mentioned sigplus. It allows you to embed photo galleries and slideshows into your Joomla! website. However, operating Phoca Gallery is not as intuitive—beginners, in particular, will need some time to familiarize themselves in order to fully utilize its features. Once you’re up and running, you’ll have access to basic functions as well as useful features like watermark integration and a download option for visitors. The free extension can be found on the Joomla! website, and on the developer’s page, where you can find detailed documentation along with additional modules and plugins for Phoca Gallery.
Showtime Image Gallery
The paid Joomla! plugin Showtime Image Gallery allows for the simple creation of professional photo galleries directly within the content management system. Users can create galleries for individual posts or pages and embed them via modules or shortcodes. With support for popular lightbox scripts like FancyBox, LightGallery, or PhotoSwipe, images can be presented in an appealing and interactive large format. Thanks to the responsive design, all galleries automatically adjust to different screen sizes. Additionally, users can assign SEO-relevant attributes such as image titles and alt texts to improve visibility in search engines. The plugin is available for download as a subscription model on the Firecoders developer studio website.
Photo Galleries for TYPO3
TYPO3 is also a popular content management system. The CMS is a highly extensible software used for both small to medium-sized websites and large enterprise solutions. As a result, the TYPO3 community is vast. However, TYPO3 is not the easiest solution if you want to create a website without much prior knowledge. Nevertheless, many companies invest time in familiarization or hire professional staff to fully leverage the benefits of the CMS. When it comes to photo galleries for websites, TYPO3 offers several professional solutions.
Simple Image Gallery (bm_image_gallery)
The TYPO3 extension Simple Image Gallery or bm_image_gallery allows for the simple creation of flexible and responsive photo galleries for websites. Users can create galleries directly from TYPO3 file collections, enabling centralized image management and reuse in multiple galleries. Clicking on an image optionally opens a lightbox, displaying the image in large format and allowing intuitive navigation through the gallery. With support for custom image sizes and TypoScript configurations, the display and layout of galleries can be adjusted to meet specific requirements. The extension is also SEO-friendly, as alt texts, titles, and descriptions can be added for each image. bm_image_gallery can be integrated into modern TYPO3 installations and is available for download in the Extensions Store of TYPO3.
ns_gallery
The TYPO3 extension ns_gallery is a paid solution for creating professional photo galleries for websites and multimedia sliders. It supports various layouts, slider displays, and zoom functions, allowing galleries to be visually adaptable to your web design. ns_gallery allows for managing images in albums and categories and also supports embedding videos, such as from YouTube.
With features like lazy loading and responsive design, both loading times and display on mobile devices are optimized. The extension also offers extensive lightbox functions. It can be tested for free for 15 days and is then available as an annual subscription or a lifetime subscription on the official website.
- Professional templates
- Intuitive customizable design
- Free domain, SSL, and email address
SEO-relevant aspects of photo galleries
Photo galleries for websites can significantly enhance your site’s visibility in search engines if they are properly optimized. This includes using descriptive file names, alt texts, and image descriptions that help search engines understand the image content. Additionally, a responsive display, fast loading times through lazy loading, and optimized image sizes contribute to performance, positively affecting your ranking.
SEO checklist for galleries
✓ Provide all images with descriptive file names
✓ Add alt texts and titles for image descriptions
✓ Optimize images for fast loading times (compression, lazy loading)
✓ Embed responsive sizes for various devices
✓ Use structured data
✓ If possible, add captions or subtitles
✓ Use internal linking to relevant content


