OG Gallery Custom Links: send every gallery image to its own page

Jellybean, the OG Nexus mascot: OG Gallery Custom Links: send every gallery image to its own page

OG Gallery Custom Links is a WordPress plugin we build at OG Nexus. It adds link fields to every image in your Media Library. Set a link once, and that image goes there every time it appears in a gallery. There is no editing page by page.

This guide covers how it works, the settings we run on og-nexus.com, and the order we would set it up in on a new site.

The problem it solves

A gallery is often more than a set of pictures. Each photo might stand for a product, an article, a portfolio piece or a partner. Visitors click the photo and expect to land on that page.

WordPress galleries do not make this easy. By default, a click opens the image file or a lightbox. You can add links by hand in some galleries, but then you repeat the work on every page that uses the same image. OG Gallery Custom Links moves the link to the image itself.

Links set in the Media Library

Each image gets Link URL, Link Target, Link Rel and ARIA label fields.

As soon as the Link URL is filled in, the image links there in every gallery it is used in.

Linked images skip the lightbox automatically, so the click goes straight to your page.

Images without a Link URL behave exactly as before.

Link Rel takes the same values as any HTML link, such as nofollow or sponsored for partner pages. MDN has a clear list of what each rel value means. The ARIA label gives screen reader users a clear name for the link, which matters when the image alone does not say where it goes.

Works with your galleries

It works with the standard WordPress gallery, the block editor gallery and OG Gallery. Other galleries work too when their images keep the standard WordPress wp-image-ID class, which is how it finds each image. Others can be supported through CSS class filters.

Pick your engine

To add the links, the plugin has to read and rewrite your page. You choose how under Parsing Engine:

HtmlDomParser. Very reliable, and it writes the links into your page HTML.

DiDom. The same idea but faster. Your HTML needs to be clean and valid.

Javascript. The fastest. Links are added in the visitor's browser instead of the page HTML.

If you care about search engines seeing the links, pick one of the first two. Javascript links are not part of the HTML that is sent.

The settings we run on og-nexus.com

OG Gallery Custom Links is active on og-nexus.com, next to OG Gallery and OG Lightbox. These are our choices:

Parsing Engine: HtmlDomParser. It is the most reliable engine, and the links end up in the HTML itself.

OB Mode: on. This lets the plugin find linked images outside the main content too, such as a header or sidebar. It slows processing, so the plugin recommends a cache. Our pages are cached by LiteSpeed Cache and the QUIC.cloud CDN.

Use Buttons: on, with the label "Click here". Linked images show a small call-to-action button.

Skip on Current Page: off.

Logs: off. They are only needed when something has to be debugged.

Settings worth knowing

Skip on Current Page. If a link points to the page the visitor is already on, it is ignored. The lightbox then works as normal instead of reloading the same page.

OB Mode. Switch it on only if linked images sit outside the post content.

Logs. Simple logging, written to the PHP error log.

Extra touches

An optional button with your own label on linked images.

A page source report showing how many images were scanned and linked.

Filters to run the plugin only on the pages that need it.

Developer filters for the link address, switching it on and permissions.

What we would do first on a new site

1

Pick HtmlDomParser unless you know your HTML is perfectly valid.

2

Open one image in the Media Library and fill in its Link URL.

3

Add an ARIA label that says where the link goes.

4

Set Link Rel to sponsored or nofollow for paid or partner links.

5

View a gallery that uses the image, and click it to check the link.

6

Switch on OB Mode only if an image outside the content needs a link.

Who it is for

Photographers, agencies, shop owners and bloggers who want gallery images to lead to products, articles, portfolios or partner pages, without rebuilding their galleries.

Getting it

OG Gallery Custom Links comes with a licence key for one site, updates and support from the OG Nexus team. See the OG Gallery Custom Links product page, the documentation, or the whole OG plugin family.

Keep reading