Open Image in New Tab

A lot of people have been asking about opening the link on the main image in a new tab or window. This is a pretty easy fix, so I thought I’d walk through the steps here.

Getting Started

All the setup should be the same as a regular PikaChoose setup.

API Hook

We’re going to change how you can PikaChoose slightly to take advantage of a hook. This way we can inject our code in where we want it.

$(document).ready(function (){
   var a = function(self){
      self.anchor.attr('target','_blank');
   };
   $("#pikame").PikaChoose({buildFinished:a});
});

Example

See wasn’t that simple? It’s almost too easy! You can view an example below:

  • Any html can be used in captions
  • A variety of options are available to style PikaChoose
  • Use custom images or let PikaChoose create thumbs for you.

2 Responses

  1. Yi Yong:

    Hi there Jeremy,

    What about multiple different usage of target=”"?

    e.g. Some using _blank, some with _self, some without target=”" (no links)

    s are generated (as a string) via backend asp.net VB code.

    Thanks

Leave a Reply