Text Image Links

Last Modified: April 25th, 2009

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

  1. July 10th, 2008 at 07:58 | #1

    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. July 18th, 2008 at 09:50 | #2

    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

  3. August 13th, 2008 at 01:17 | #3

    Thank you for this!

  4. September 11th, 2008 at 08:04 | #4

    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

  5. September 11th, 2008 at 08:23 | #5

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

  6. September 12th, 2008 at 12:55 | #6

    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/

  7. September 12th, 2008 at 13:03 | #7

    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!

  8. HIllel
    September 30th, 2008 at 11:08 | #8

    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!

  9. September 30th, 2008 at 21:19 | #9

    @ 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

  10. October 9th, 2008 at 14:05 | #10

    LOVE the plugin

  11. October 9th, 2008 at 14:09 | #11

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

  12. November 5th, 2008 at 15:30 | #12

    very usefull
    thanks :)

  13. kalamari
    February 26th, 2009 at 06:26 | #13

    Hey, great plugin, I have one question though.

    I want to add #photo to the generated URL, how can I do that?

  14. February 27th, 2009 at 15:36 | #14

    @kalamari
    On line 47 on the source code you will find this line:
    return '<a href="' . get_attachment_link( $attachments[$k]->ID ) . '">' . $link_text . '</a>';

    You can add your #photo like this:

    return '<a href="' . get_attachment_link( $attachments[$k]->ID ) . '#photo">' . $link_text . '</a>';

    Please note that this will add an id of “photo” to all links generated by this plugin.

    Hope this helps,

  15. March 27th, 2009 at 16:47 | #15

    Thanks for the plugin! Very helpful!

  1. No trackbacks yet.