Linking gallery images to the attachment page in Easy Image Gallery

This tutorial will show you how to link each image to the attachment page, instead of using the lightbox functionality.

Easy Image Gallery can either open your gallery images in a lightbox, or simply display them with no links. A user contacted me today asking if it’s possible to link each image to the attachment page, instead of using the lightbox functionality.

To do this, copy the following function into your child theme’s functions.php (mind the opening PHP tag) or custom plugin:

Note: if you need to add a CSS class on the anchor link, simply comment out the line of code shown in the code snippet and edit accordingly.

You can download Easy Image Gallery from WordPress.org.

fancyBox and Easy Image Gallery v1.1

Up until this point, Easy Image Gallery has been packaged with fancyBox 2. Unfortunately I completely overlooked the licensing of fancyBox 2, which is licensed under the Creative Commons license. Non-GPL licensed software cannot be hosted on the WordPress repository and because of this, I’ve replaced fancyBox 2 with fancyBox 1, which is GPL licensed.

If you’d like to add fancyBox 2 back into the plugin, simply download the free Easy Image Gallery Extend plugin. After activation, you’ll find fancyBox 2 (as well as Colorbox) under the plugin’s settings.

Different thumbnail sizes for each post type with Easy Image Gallery

By default, Easy Image Gallery uses the thumbnail image size for the thumbnail images in the gallery. Here’s how you can specify a different thumbnail size for each post type. For example, you could use one size for Posts, and a completely different size for Pages.

Copy and paste the following function below (mind the opening PHP tag) into your child theme’s functions.php or custom plugin, and adjust the values as required for each post type. You can also easily add your own custom post types if you have any. This code required Easy Image Gallery v1.0.5 or newer.