Skip to content

Gallery with captions and credits in WordPress

Photos with a proper caption, the photographer's name and the reuse licence.

Here is an excerpt of this component's code in WordPress. The full code is free for members, ready to copy into your project.

This component also comes in

Open in a new tab

The code in WordPress

galerie-legendes-credits.php
<?php
/**
 * Plugin Name: Forge, Galerie avec légendes et crédits
 * Description: Des photos accompagnées d’une vraie légende, du nom du photographe et de la licence de réutilisation. Ajoute la composition « Galerie avec légendes et crédits » à l'éditeur de blocs.
 * Version: 1.0.0
 * Requires at least: 6.6
 * Requires PHP: 8.1
 * Author: Forge
 * License: GPL-2.0-or-later
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain: forge-galerie-legendes-credits
 *
pattern.html
<!-- wp:html -->
<section class="glc" data-glc aria-labelledby="glc-titre">
        <p class="glc-eyebrow">Office de tourisme du Vercors · photothèque</p>
        <h2 class="glc-title" id="glc-titre">Le Vercors en images</h2>
        <p class="glc-lead">Chaque photo indique son auteur et ses conditions de réutilisation.</p>
        <ul class="glc-grid" role="list">
          <li class="glc-item glc-first">
            <figure class="glc-figure">
              <div class="glc-art glc-art-first" role="img" aria-label="Les falaises du Mont Aiguille au lever du jour" style="--glc-bg: radial-gradient(circle at 75% 30%, #fde3a7 0 6%, transparent 7%), linear-gradient(180deg, #f6c99a 0 30%, transparent 30%), linear-gradient(100deg, transparent 30%, #6b5a4e 30% 34%, #8b7563 34% 62%, #6b5a4e 62% 66%, transparent 66%) 0 100%/100% 75% no-repeat, linear-gradient(180deg, #f2b98b, #b9c9a3 70%, #6f8d55 70%)"></div>
              <figcaption class="glc-caption">
                <span class="glc-name">Les falaises du Mont Aiguille au lever du jour</span>
                <span class="glc-text">Depuis le belvédère de Chichilianne, à vingt minutes de marche du parking.</span>
style.css
:root {
  --glc-card: #ffffff;
  --glc-text: #1d2228;
  --glc-muted: #525b66;
  --glc-line: #dde3e8;
  --glc-accent: #0f5f74;
  --glc-soft: #e6f2f5;
  --demo-galerie-legendes-credits-bg: #eceff2;
  --demo-galerie-legendes-credits-text: #1d2228;
}

@media (prefers-color-scheme: dark) {

Free component: copy it freely, including for commercial projects.

Galleries and carousels components in WordPress
  • A product photo that zooms in under the pointer, and from the keyboard with Enter and the arrow keys, to inspect the details.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • Building site photos sorted by dated step on a vertical timeline, with the current step highlighted.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • YouTube videos shown as thumbnails: the player only loads on click, to respect privacy and keep the page light.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A slideshow that fills the whole screen, browsed with the keyboard or a finger swipe, and closed with Escape.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component