Text-based Image Links

Tired of the default thumbnail links that WordPress generates when using the gallery shortcode? I have made a plugin that allows users to add text based navigation to a WordPress gallery in just a few minutes. Just follow these simple steps:

Install

  1. Download the appropriate version for the list below.
  2. Un zip the package and upload to your /wp-content/plugins/ directory.
  3. Log into WordPress and navigate to the “Plugins” Panel.
  4. Activate the plugin.
    NOTE: if you were using the workaround I posted a few months back, you will need to open /wp-content/themes/your-theme/functions.php and delete the “mf_image” functions found therein.

Configure Template

If your current theme does not have an image.php file, I would suggest that you visit your theme’s homepage and see if a new version has been released for 2.5+. If no new version is available, you can save a copy of the WordPress default theme’s image.php file to your current theme’s directory and modify it match your current theme.

Locate the following two functions:

 
<?php previous_image_link() ?>
<?php next_image_link() ?>

Replace these functions with the following functions. NOTE: You can change the parameters to whatever string that you like.

 
<?php mf_previous_image_link('Previous Image') ?>
<?php mf_next_image_link('Next Image') ?>

You should now save image.php and upload it to your production server and visit your site to see text-based navigation links on all of your WordPress Galleries.

Download

Comments

13 Responses to “Text-based Image Links”

  1. Nick on July 10th, 2008 7:58 am

    GREAT!!! I will install it on my test server for WordPress 2.6. I guess that this is the final step for making my theme ready for WP 2.6!

    KUDOS!!!

  2. nickbohle.de | The Morning After - WordPress 2.6, anyone? on July 11th, 2008 4:50 am

    [...] you visit mfields.org and download the plug-in mf_image_links_v1.1. Upload the plug-in to your plug-in folder and activate it after you have finished the upgrading [...]

  3. tommy on July 18th, 2008 9:50 am

    mfields,

    I put this on a site I’m working on and it fixed me up without a hitch. Props on a solid plugin.

    -tommy

  4. WordPress 2.5 Gallery - Helpful Links | The Mercer Journal on July 30th, 2008 3:53 pm

    [...] Step Three - Create an image.php File So now that you have a gallery post with thumbnails, the larger version of your photo needs somewhere nice to be displayed when you click on the thumbnail. I noticed that when I clicked on my thumbnails, my photos were displayed in my single.php file. This was not optimal because it had all the stuff under the photo that would normally be displayed under one of my individual posts (like my signature image and my links to similar posts.) Also, my photo had no “next photo,” “previous photo” links, so navigation was clunky at best. Turns out, I needed an image.php file for my photos. This comes with the default theme in WordPress 2.5, but many other themes don’t include it. LINK: Adding Text Links to WordPress Gallery Michael Fields has done a wonderful job explaining all you need to do to set up your image.php file, and how to customize the look of your “previous” and “next” navigation. It took a little bit of time to customize the php file for my theme’s css, but it was worth it in the end. UPDATE for Version 2.6 - posted July 30 - Michael now has a plugin to make things even easier! Visit Here. [...]

  5. Mike on August 13th, 2008 1:17 am

    Thank you for this!

  6. eckert on September 11th, 2008 8:04 am

    i’m getting this error:
    Warning: Cannot modify header information - headers already sent by (output started at /nfs/c02/h07/mnt/39587/domains/yntmedia.com/html/specialsections/wp-includes/functions.php:2328) in /nfs/c02/h07/mnt/39587/domains/yntmedia.com/html/specialsections/wp-includes/pluggable.php on line 770

  7. eckert on September 11th, 2008 8:23 am

    nevermind, i overwrote the affected files and now it appears to be working correctly. thanks!

  8. Houston Graham on September 12th, 2008 12:55 pm

    Michael,

    I’m having trouble getting this to work. I have WP 2.6.1 and have the plugin activated (version 1.1) but I still see thumbnails for the Prev/Next navigation. I’ve even used the Default theme to see eliminate any confusion on that end. I don’t need to do the Configure Template step in your post, do I?

    Here’s an example in the gallery: http://www.headheartballs.com/gallery/prod_screening1/

  9. Houston Graham on September 12th, 2008 1:03 pm

    Nevermind my last comment, you can delete it. Figured out that I had to also do that Configure Template step. :) Thanks for the great plugin!

  10. HIllel on September 30th, 2008 11:08 am

    Hi Michael:

    Your plug-in works great.

    Two feature requests:

    1. On the first page of a gallery the previous image link should disappear. And correspondingly, on the last page of the gallery, the next image link should disappear.

    2. Also, it would be great for SEO if there was an option to replace the “previous image”/”next image” text with the name of the image you’re linking to.

    Thanks!

  11. mfields on September 30th, 2008 9:19 pm

    @ HIllel,
    Hi. Thanks for the compliment!

    Feature requests:

    1. The previous image “link” does not print. In my opinion, it was better to print the link text with in a span tag that I gave a class of “inactive” to. this way, the user could choose (via css) whether or not the link appeared on the page. Try the following on your themes’ style.css:

    .inactive{display:none;}

    2. This doesn’t seem to be to hard to work in and I have added it to the todo list in my svn version.

    Thanks for you comments and insight!
    -Mike

  12. Trey Cruz on October 9th, 2008 2:05 pm

    LOVE the plugin

  13. Trey Cruz on October 9th, 2008 2:09 pm

    One question… is there any way to link back to the parent POST of an image?

Leave a Reply