Legacy Gallery Links releases
Legacy WordPress Gallery Custom Links
by Fernando Tellado · github.com/fernandotellado/legacy-gallery-links · website
Install
The author publishes release zips, so WP-CLI can install straight from GitHub:
wp plugin install https://github.com/fernandotellado/legacy-gallery-links/releases/download/1.1.0/legacy-gallery-links.zipSend each image of a classic WordPress gallery to any URL you want.
Published here only, not in the WordPress.org plugin directory. Grab the latest release.
By default, clicking a gallery image takes you to the image file or its attachment page. Neither helps when the picture is a product, a client, a sponsor or a portfolio piece and the click should go somewhere that matters. This plugin adds a link field to every image, set once and used everywhere that image appears in a gallery.
Say you keep a grid of sponsor logos on a page. Out of the box every logo opens a full size PNG of itself. With this plugin each logo goes to that sponsor's website, in a new tab, with rel="sponsored", and the one sponsor who asked not to be linked is simply not clickable.
It also happens to be a way out for sites left stranded when WP Gallery Custom Links was closed in 2019: it reads the exact same attachment fields, so there is nothing to import and nothing to re-edit.
Not to be confused with Meow Apps' Gallery Custom Links, a different and actively maintained plugin. This one is built around the fields left by johnogg's closed plugin, and warns you if both are active.
How it works, in three steps
- Open an image in the media library, or click it while editing a gallery.
- Fill in Gallery Link URL in the panel on the right. That is the whole setup: one field.
- Look at the gallery. Every gallery holding that image now sends visitors to your URL instead of to the image file.
Site wide behaviour (new window or same window, rel, lightbox handling) lives under Media → Gallery Links. Nothing is written to your posts: the link travels with the image.
Screenshots
The field, on the image itself. Right there while you edit the gallery, no extra screen to visit.

The audit. Which galleries use your linked images, what each image linked to before, and what it goes to now.

The media library. A Gallery link column you can sort by, plus a filter, so the whole set is visible at a glance.

The settings. Site wide defaults for anything an image does not decide on its own.

What you get
- A link field on every image, used everywhere that image appears in a gallery.
- Same window or new window, site wide or per image.
- A
relvalue on your custom links, fornofollow,sponsoredor whatever you need. - Lightbox handling, so the custom link wins the click instead of opening an overlay.
- A Do not link this image tick box, for an image that is simply not clickable.
- Extra CSS classes per image.
- A Gallery link column in the media library, sortable and with a filter for the images that carry one, so you can see the whole picture without opening images one by one.
- An audit of the whole site, exportable to CSV.
Where it applies
Galleries built with the [gallery] shortcode, which is what the classic editor produces. The gallery block is deliberately left alone: it already lets you link each image wherever you want, so there is nothing to add.
The plugin never writes to post_content. That is a deliberate limit, since rewriting content is where migrations break sites.
Per gallery: shortcode attributes
Everything above is set per image and applies everywhere that image is used. When one particular gallery needs to behave differently, these attributes override it, and they are the same ones WP Gallery Custom Links used, so galleries written years ago keep working exactly as they did.
| Attribute | What it does |
|---|---|
ignore_gallery_link_urls="true" |
Leaves this gallery completely alone. Normal WordPress links, as if the plugin were not installed. |
open_all_in_new_window="true" |
Every custom link in this gallery opens in a new window, whatever each image says. rel="noopener" is added for you. |
open_all_in_same_window="true" |
The opposite: everything opens in the same window. |
remove_links="true" |
Strips the link from every image in this gallery, custom or not. The image ends up inside a <span class="no-link">. |
preserve_click_events="true" |
Lets the lightbox win the click in this gallery instead of the custom link. |
rel="nofollow sponsored" |
Sets rel on the links of this gallery. Unlike the site wide setting, this one applies to every image in the gallery, not only to those carrying a custom link. |
[gallery ids="12,34,56" link="file" open_all_in_new_window="true" rel="sponsored"]
Two things worth knowing about [gallery] itself:
link="none"renders no<a>at all, so there is nothing for the plugin to replace. That was the usual reason the old plugin looked broken, and the audit flags it for you. Uselink="file"orlink="post".- Attributes only take
"true"as a yes. Anything else counts as not set.
For developers
Filter the stored URL before it is applied, kept from the old plugin so existing snippets keep working:
add_filter( 'wpgcl_filter_raw_gallery_link_url', function ( $url, $attachment_id, $post_id ) {
// Add a campaign parameter to every custom gallery link.
return add_query_arg( 'utm_source', 'gallery', $url );
}, 10, 3 );
Markup the plugin produces, in case you want to style it:
- Custom links get the lightbox exclusion class,
no-lightboxby default and configurable in the settings, plus any extra classes set on the image. target="_blank"always comes withrel="noopener", whatever else is inrel.- A removed link leaves the image inside
<span class="no-link">, keeping the layout intact.
Coming from WP Gallery Custom Links
Nothing to import. The links you set years ago are read from the same four attachment meta keys:
| Field | Meta key | Notes |
|---|---|---|
| Gallery Link URL | _gallery_link_url |
Custom URL, or [none] to remove the link. The Do not link this image tick box stores that same marker, so you never have to type it. |
| Open in | _gallery_link_target |
_self or _blank. |
| Lightbox | _gallery_link_preserve_click |
remove or preserve. |
| Extra CSS classes | _gallery_link_additional_css_classes |
Added to the <a>. |
The per-gallery shortcode attributes and the wpgcl_filter_raw_gallery_link_url filter are kept too, so galleries and snippets written for the old plugin keep working. Both are documented above.
The Tools tab handles the rest of the handover:
- Audit the whole site: how many images carry a link, which galleries use them, what each points to before and after.
- Flags galleries set to
link="none", which render no link at all and were the usual reason the old plugin looked broken. - Check renders your real galleries and counts how many links actually came out, which catches a theme that replaces the gallery markup. It goes through every entry the audit found, in batches, showing progress as it works, and names the theme or plugin responsible when links go missing. It also says what it could not see, such as galleries living in page builders or reusable blocks, so a clean result is never read as more than it is.
- Download as CSV, one row per image, with a column saying whether the link is being applied and why not when it is not.
Because the old plugin hooks galleries earlier than this one, you can install this, read the audit, and only then deactivate the old one. The handover is instant, with no gap.
While the old plugin is active, a notice on the Settings tab says so and will not go away: nothing on that tab applies yet, since the old plugin keeps winning. It clears itself the moment you deactivate it.
Better than the original
- URLs are escaped on output. The original injected them raw, a stored XSS hole.
- The gallery renders once, not twice, so gallery IDs and CSS stay correct (no more
#gallery-2). - No JavaScript needed to keep lightboxes away.
target="_blank"always getsrel="noopener".- Images repeated in the same gallery are handled properly.
Requirements
WordPress 6.0+, PHP 7.4+.
Installation
This plugin is not in the WordPress.org directory. It is published here and nowhere else.
-
Download the zip from the latest release, then upload it in Plugins → Add New → Upload Plugin.
Or clone it straight into your plugins folder:
git clone https://github.com/fernandotellado/legacy-gallery-links.git wp-content/plugins/legacy-gallery-links -
Activate.
-
Open an image in the media library and fill in the Gallery Link URL field. Site wide options live under Media → Gallery Links, on the Settings tab.
Updates
There are none to wait for: nothing on WordPress.org points at this plugin, and it does not call home. Watch this repository, or check the releases now and then, and install the newer zip over the old one.
The plugin header carries Update URI: false, so WordPress will never offer you an update from wordpress.org for it, even if some unrelated plugin is published there under the same slug.
Translations
The languages/legacy-gallery-links.pot template is included. Open it in Poedit to start a translation.
Uninstalling
Removes only the plugin's own settings. Your links stay on the images, so any other tool can still read them.
Support
Need help or have suggestions? Open an issue, which is the only support channel: there is no WordPress.org forum for this plugin.
Love the plugin? Star the repository and help spread the word!
About AyudaWP.com
We are specialists in WordPress security, SEO, AI and performance optimization plugins. We create tools that solve real problems for WordPress site owners while maintaining the highest coding standards and accessibility requirements.
License
GPL-2.0-or-later. Full text in LICENSE.
Releases
2 releases. Each count is every asset in that release; expand a row for the breakdown.