Get the title attribute into a lightbox frame I've been exploring and getting somewhat close to what I want (getting the value of the title attribute into my lightbox frame) by reading documentation 
and this topic here at Drupal Answers.

I'm working with a custom tpl.php file with the following code (copied from elsewhere):

   if($id == 'field_afbeelding') {
            $samples = explode(';', $fields['field_werken_afbeelding_sampl']-&gt;content);
            $originals = explode(';', $field-&gt;content);
            for($i = 0; $i &lt; count($samples); $i++) {
                print l($samples[$i], $originals[$i], array('html' =&gt; TRUE, 'attributes' =&gt; array('rel' =&gt; 'lightbox')));
            }
        }


From what I gathered in the documentation, it appears that I need to insert the lightmodal[][] array-thing into my code right at the end, where it says array('rel' =&gt; 'lightbox').

In the Drupal Answers topic, the question starts off about how to insert a CCK field (or a caption or whatever) into a lightbox, but ends about how to get the title attribute. 

The very last comment says - I quote : 'Type &lt;pre&gt;&lt;?php print_r($node); ?&gt;&lt;/pre&gt; in node.tpl.php to see what's available in the node object (what fields, how formatted, etc.) and then take what you want and output it to the lightbox. I hope that's what you need..'

In my case, it's a view, so I went with devel module, going &lt;?php global $field; dpm($fields);?&gt;

Now as for 'take what you want and output it to the lightbox', the problem is I don't recognize out of these clickable Krumo blocks what I need. I do get these Krumo blocks that the devel module shows where you can click in the them and explore those elements/objects/whatever you want to call them.

I've been expanding all of the arrays and been seing 'title' in nested arrays. I guess the question boils down to what exactly must I put in this lightmodal[][] array if I'm right about the lightmodal thing?

And, before you ask, I made sure than in CCK, when editing the image field, I have alt and title attribute checkboxes checked and also given values to the images at hand.
There are multiple issues for Lightbox about your problem. Atm your best chance is indeed to override the relevant tpl.php file. This would be in the form of views-view-field--viewid--fieldname.tpl.php. The variables exposed in there that are of interest are the following:


$output: The processed output that will normally be used.
$row: The raw SQL result that can be used.


The first one indeed contains a string in the form of:

&lt;a 
  href="http://www.example.com/sites/default/files/styles/large/public/img.png?itok=Tn9Y1Pyo" 
  rel="lightbox[field_image][]"&gt;
    &lt;img 
      typeof="foaf:Image" 
      src="http://www.example.com/sites/default/files/styles/lines_thumbnail/public/img.png?itok=shRRK" alt="" /&gt;
&lt;/a&gt;


The above should become something like this:

&lt;a 
  href="http://www.example.com/sites/default/files/styles/large/public/img.png?itok=Tn9Y1Pyo" 
  rel="lightbox[field_image][&lt;p&gt;CAPTION&lt;/p&gt;]"&gt;
    &lt;img 
      typeof="foaf:Image" 
      src="http://www.example.com/sites/default/files/styles/lines_thumbnail/public/img.png?itok=shRRK" alt="" /&gt;
&lt;/a&gt;


in order to have a caption in your lightbox.

You could of course use a replace function in order to achieve this, such as your attempted solution.

What I recommend is to use the $row variable to obtain the data itself and construct the output however you wish, for instance to add a title in &lt;a&gt; as well and why not solve the empty alt attribute value issue as well for the sake of SEO:

&lt;?php
  //print $output; 
  //dpm($output); 
  //dpm($row);
  $caption = $row-&gt;taxonomy_term_data_name, // HERE use your field of choice
  print l(
    theme_image_style(array(
      'style_name' =&gt; 'thumbnail',
      'path' =&gt; $row-&gt;field_field_image[0]['raw']['uri'],
      'alt' =&gt; $caption,
      'attributes' =&gt; array('typeof' =&gt; 'foaf:Image'),
      'width' =&gt; NULL,
      'height' =&gt; NULL,
    )),
    image_style_url('large', $row-&gt;field_field_image[0]['raw']['uri']),
    array(
      'attributes' =&gt; array(
        'title' =&gt; $caption,
        'rel' =&gt;
          'lightbox[field_image][&lt;p&gt;' . $caption . '&lt;/p&gt;]',
      ),
      'html' =&gt; TRUE,
    )
  );
?&gt;