• Hi all,

    I was just wondering if there is any way that an image in a post can link to a different address depending on whether it is being viewed in the single post itself or in the index or any archice/category listing?

    What I want is for the user to be able to click on a picture when it is being shown as part of a post in the archives or on the main index listing of posts, but once the user gets through to the post itself, that they are able to click on the image and the link is to the (larger version) of the image itself, not to the post as before. This latter behaviour is to allow a lightbox plugin to make the image bigger.

    Does anybody have any ideas as to how to go about doing this?

    Many thanks,

    Rory. 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter wp-rory

    (@wp-rory)

    …bump…any ideas on this one? I want the user to be able to click through to a post by clicking on its image in the archive or category page, but then to be able to click on the image in the actual post so that it opens in lightbox (link is to the full-size image itself).

    Here’s hoping,

    Rory. 🙂

    Thread Starter wp-rory

    (@wp-rory)

    OK I have found the solution! I will put in here in case somebody has read this thread and thought ‘that’s what I want to do’ – here you are, your search is over! 🙂


    Step 1: Install and activate the Lightbox 2 Plugin. Go to Settings > Lightbox 2 and tick the box called ‘Auto-lightbox image links’.
    Step 2: Write a new post. Upload an image. In the image options area, ensure that the size is set to thumbnail, and that the link is set to the Post URL. Insert the image.
    Step 3: Verify that this is working. Go to your posts page and click on the image thumbnail. It should take you through to the post. Now click again on the image. It should pop up in full size in the lightbox. Super!

    Note: other lightbox plugins may also work – this is just the first one that I tried.

    All the best,

    Rory. 🙂

    Thread Starter wp-rory

    (@wp-rory)

    Update time 🙂

    Upon closer inspection it seems that the steps above do not achieve exactly the result I wanted. The user has to click the image thumbnail in the post archive but then click on it again in the post itself to open it in Lightbox, but if they happen to click on the title link of the post in the archive, they then get through to the post itself but if they click on the image at that stage, they go through to a larger version of the image which they then have to click on to open it in Lightbox. So for some reason there is that mysterious third stage that appears with the current settings.

    So my new approach is to define the image link as the image file URL itself. In this way, if the user clicks on the image in the post archive, it opens in the Lightbox, or if they click on the post title they get through to the post itself and again has the opportunity to click on the image to see it in the Lightbox. This is not exactly what I wanted but I think it will work in the mean time whilst I try to find a better way…

    All the best,

    Rory. 🙂

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Image link behaviour’ is closed to new replies.