title: lightbox dynamic image retrieval
body: <p>I am constructing a lighbox gallery, currently experimenting with FancyBox (http://fancybox.net) and ColorBox (http://colorpowered.com/colorbox).</p>
  
  <p>By default you have to include a link to the large version of the image so that the Lightbox can display it. However, I am wanting to have the image link URLs pointing to a script rather than directly to the image file. So for example, instead of:</p>
  
  <pre><code>&lt;a href="mysite/images/myimage.jpg"&gt;
  </code></pre>
  
  <p>I want to do:</p>
  
  <pre><code>&lt;a href="mysite/photos/view/abc123"&gt;
  </code></pre>
  
  <p>The above URL points to a function:</p>
  
  <pre><code>public function actionPhotos($view)
  {
      $photo=Photo::model()-&gt;find('name=:name', array(':name'=&gt;$view));
  
      if(!empty($photo))
      {
          $user=$photo-&gt;user;
  
          $this-&gt;renderPartial('_photo', array('user'=&gt;$user, 'photo'=&gt;$photo, true));
      }
  }
  </code></pre>
  
  <p>At some point in the future the function will also update the view count of the image.</p>
  
  <p>Now this approach is working to an extent - most images load up but some do not load up (the lightbox gets displayed in a malformed state). I think the reason for this is because it is not processing the function quick enough. For example when I click the "next" button it needs to go to the URL, process the function and retreive/output the response.</p>
  
  <p>Does anybody know how I can get this working properly?</p>