Skip to content
lightbox2.module 61.7 KiB
Newer Older
Stella Power's avatar
Stella Power committed
// $Id$

 * Enables the use of lightbox2 which places images above your current page,
 * not within. This frees you from the constraints of the layout,
 * This module is for Drupal 6.x only.
 *
 * Module by: Mark Ashmead
 * Mailto: bugzie@gmail.com
Stella Power's avatar
Stella Power committed
 * Co-maintainer: Stella Power (http://drupal.org/user/66894)
Stella Power's avatar
Stella Power committed
function lightbox2_help($path, $arg) {
  switch ($path) {
    case 'admin/modules#description':
      return t('Enables Lightbox2 for Drupal');
    case 'admin/help#lightbox2':
      return t('<h3>Overview</h3>
      <p align="justify">Lightbox2 JS is a simple, unobtrusive script used to overlay images on the current page. It\'s a snap to setup and works on all modern browsers. The module comes with a Lightbox2 Lite option which does not use the JQuery libraries; it is therefore less likely to conflict with anything else.</p>
      <p align="justify">Places images above your current page, not within. This frees you from the constraints of the layout, particularly column widths. Keeps users on the same page. Clicking to view an image and then having to click the back button to return to your site is bad for continuity (and no fun!).</p>
Stella Power's avatar
Stella Power committed
<h3>Features</h3>
The version 2 module has several benefits over the plain Lightbox module.  Note, not all of these features are available when the "Lightbox2 Lite" option is enabled.
<ul>
<li>Image Sets: group related images and navigate through them with ease - ideal for your image galleries.</li>
Stella Power's avatar
Stella Power committed
<li>Slideshow Capability: automatically transition between grouped images, includes play/pause and previous and next buttons.</li>
<li>HTML Content Support: ability to show websites or other HTML content in a lightbox.</li>
Stella Power's avatar
Stella Power committed
<li>Video Content Support: ability to show videos in a lightbox.</li>
Stella Power's avatar
Stella Power committed
<li>Visual Effects: fancy pre-loader and transition when you click on the image.</li>
<li>Keyboard Shortcuts: useful <a href="http://drupal.org/node/249827">keyboard shortcuts</a> for switching between images, toggling play / pause, etc.</li>
Stella Power's avatar
Stella Power committed
<li>Zoom Capability: larger images are reduced in size so they fit snugly inside the browser window.  A zoom button can then be clicked on to see it in its original size.</li>
<li>Automatic Image Detection: configurable automatic re-formatting of
image thumbnails, so there is no need to add \'rel="lightbox"\' to each
image link on your site.  <a
Stella Power's avatar
Stella Power committed
href="http://drupal.org/project/image">Image</a>, <a
href="http://drupal.org/project/inline">Inline</a>, <a
href="http://drupal.org/project/flickr">Flickr</a>, <a
Stella Power's avatar
Stella Power committed
href="http://drupal.org/project/img_assist">Image Assist</a> and <a
href="http://drupal.org/project/imagefield">CCK Imagefield</a> modules are all
Stella Power's avatar
Stella Power committed
supported.  It\'s also possible to configure a custom list of image classes
which should trigger the lightbox functionality.</li>
Stella Power's avatar
Stella Power committed
<li><a href="http://drupal.org/project/imagecache">Imagecache</a> Support: adds a Lightbox2 field formatter for <a href="http://drupal.org/project/imagefield">CCK imagefields</a> for your custom <a href="http://drupal.org/project/views">views</a>.</li>
<li>Image Page Link: a link to the image node can be provided within the lightbox itself.</li>
Stella Power's avatar
Stella Power committed
<li>Page Exclusion Capability: exclude certain pages on your site from having the lightbox2 functionality.</li>
Stella Power's avatar
Stella Power committed
<li>Login Support: ability to modify all user/login links so the login form appears in a lightbox.</li>
<li>Skin and Animation Configuration: configure the order and speed of the lightbox animations, along with the lightbox colors, border size and overlay opacity.</li>
Stella Power's avatar
Stella Power committed
<li>Gallery 2 Support: support for Gallery 2 images via the <a href="http://drupal.org/project/gallery">Gallery</a> module (beta).</li>
</ul>
Stella Power's avatar
Stella Power committed
<p align="justify"><h3>Usage</h3></p>
      <h5 style="text-decoration: underline;">Adding a Basic Lightbox</h5>
      <p>Add rel=&quot;lightbox&quot; attribute to any link tag to activate the lightbox. For example: </p>
      <p>&lt;a href=&quot;image-1.jpg&quot; rel=&quot;lightbox&quot;&gt;image #1&lt;/a&gt;</p>
      <p>&lt;a href=&quot;image-1.jpg&quot; rel=&quot;lightbox[][my caption]&quot;&gt;image #1&lt;/a&gt;</p>
      <p>Optional: To show a caption either use the title attribute or put in the second set of [] of the rel attribute.</p>
Stella Power's avatar
Stella Power committed
<h5 style="text-decoration: underline;">Grouping Images</h5>
   <p>If you have a set of related images that you would like to group, follow
   step one but additionally include a group name between square brackets in the
   rel attribute. For example:</p><p>&lt;a href="images/image-1.jpg"
   rel="lightbox[roadtrip]"&gt;image #1&lt;/a&gt;<br />
&lt;a href="images/image-2.jpg" rel="lightbox[roadtrip][caption 2]"&gt;image
#2&lt;/a&gt;<br />
&lt;a href="images/image-3.jpg" rel="lightbox[roadtrip][caption 3]"&gt;image
#3&lt;/a&gt;<br /></p>
Stella Power's avatar
Stella Power committed
<p>No limits to the number of image sets per page or how many images are allowed
Stella Power's avatar
Stella Power committed
in each set.</p>

<p>If you have a set of images that you would like to group together in a lightbox, but only wish for one of these images to be visible on your page, you can assign the "lightbox_hide_image" class to hide the additional images.  For example:</p>

<p>&lt;a href="images/image-1.jpg" rel="lightbox[roadtrip]"&gt;image #1&lt;/a&gt;<br />
&lt;a href="images/image-2.jpg" rel="lightbox[roadtrip]" class="lightbox_hide_image"&gt;image #2&lt;/a&gt;<br />
&lt;a href="images/image-3.jpg" rel="lightbox[roadtrip][caption 3]" class="lightbox_hide_image"&gt;image #3&lt;/a&gt;</p>
Stella Power's avatar
Stella Power committed

<h5 style="text-decoration: underline;">Slideshow</h5>
<p>This is very similar to the grouping functionality described above.  The only difference is that "rel" attribute should be set to "lightshow" instead of "lightbox".  Using the same example as above, we could launch the images in a slideshow by doing:</p>

<p>&lt;a href="images/image-1.jpg" rel="lightshow[roadtrip]"&gt;image #1&lt;/a&gt;<br />
&lt;a href="images/image-2.jpg" rel="lightshow[roadtrip][caption 2]"&gt;image #2&lt;/a&gt;<br />
&lt;a href="images/image-3.jpg" rel="lightshow[roadtrip][caption 3]"&gt;image #3&lt;/a&gt;</p>
Stella Power's avatar
Stella Power committed
<h5 style="text-decoration: underline;">Video Content</h5>
<p>
It\'s possible to show video content in the lightbox.  In this case the "rel" attribute should be set to <code>lightvideo</code>.  It\'s not possible to group videos but it is possible to control the size of the lightbox by setting the \'width\' and \'height\' properties.  The properties can be configured like <code>lightvideo[width:300px; height: 200px;]</code> and <code>lightvideo[width:300px; height: 200px;][my caption]</code>.  The properties should all be of the format "property: value;" - note the closing semi-colon.  If no properties are set, then the default width and height of 400px will be used.  See below for more detailed examples.</p>
Stella Power's avatar
Stella Power committed

<p>Basic example:<br />
<code>
&lt;a href="http://video.google.com/videoplay?docid=1811233136844420765" rel="lightvideo"&gt;Google video example - default size&lt;/a&gt;<br />
</code></p>

<p>Basic example with caption:<br />
<code>
&lt;a href="http://video.google.com/videoplay?docid=1811233136844420765" rel="lightvideo[][my caption]"&gt;Google video example - default size&lt;/a&gt;<br />
</code></p>

Stella Power's avatar
Stella Power committed
<p>Controlling lightbox size example:<br />
<code>
&lt;a href="http://video.google.com/videoplay?docid=1811233136844420765" rel="lightvideo[width:400px; height:300px;][my caption]"&gt;Google video example - custom size&lt;/a&gt;<br />
Stella Power's avatar
Stella Power committed
</code></p>

<p>Supported Video Formats<br />
asx, wmv, mov and swf videos should all be supported.  A number of video providers are also supported, for example YouTube and Google Video.  For full details on how to integrate these with lightbox, please see the online documentation.</p>

<h5 style="text-decoration: underline;">HTML Content</h5>
<p>It\'s possible to show webpage content in the lightbox, using iframes.  In this case the "rel" attribute should be set to <code>lightframe</code>.  Again it\'s possible to group the items, (e.g. <code>lightframe[search]</code>) but in addition to that, it\'s possible to control some of the iframe properties.  It\'s possible to set the \'width\', \'height\' and \'scrolling\' properties of the iframe.  The properties are separated from the group name by a <code>|</code>, for example <code>lightframe[search|width:100px;]</code> and <code>lightframe[search|width:120px][my caption]</code>.  If no grouping is being used, then the <code>|</code> is still used and the format would be <code>lightframe[|width:100px;]</code>.  The properties should all be of the format "property: value;" - note the closing semi-colon.  If no iframe properties are set, then the default width and height of 400px will be used.  See below for more detailed examples.</p>
Stella Power's avatar
Stella Power committed

<p>Basic example:<br />
<code>
&lt;a href="http://www.google.com" rel="lightframe[][Search Google]"&gt;Search google&lt;/a&gt;
Stella Power's avatar
Stella Power committed
</code></p>

<p>Grouped example:<br />
<code>
&lt;a href="http://www.google.com" rel="lightframe[search]"&gt;Search google&lt;/a&gt;<br />
&lt;a href="http://www.yahoo.com" rel="lightframe[search][Search Yahoo]"&gt;Search yahoo&lt;/a&gt;
Stella Power's avatar
Stella Power committed
</code></p>

<p>Controlling iframe property example:<br />
<code>
&lt;a href="http://www.google.com" rel="lightframe[|width:400px; height:300px; scrolling: auto;]"&gt;Search google&lt;/a&gt;
</code></p>

<p>Controlling iframe property when grouped example:<br />
<code>
&lt;a href="http://www.google.com" rel="lightframe[search|width:400px; height:300px; scrolling: auto;]"&gt;Search google&lt;/a&gt;<br />
&lt;a href="http://www.yahoo.com" rel="lightframe[search|width:400px; height:300px;][Search Yahoo]"&gt;Search yahoo&lt;/a&gt;
</code></p>

<h5 style="text-decoration: underline;">Inline Content Support</h5>
<p>It\'s possible to show HTML snippets in the lightbox, that is on the same domain.  In this case the "rel" attribute should be set to <code>lightmodal</code>.  Again it\'s possible to group the content, (e.g. <code>lightmodal[search]</code>) but in addition to that, it\'s possible to control some of the inline / modal properties.  It\'s possible to set the \'width\', \'height\' and \'scrolling\' properties of the inline content.  The properties are separated from the group name by a <code>|</code>, for example <code>lightmodal[search|width:100px;]</code> and <code>lightmodal[search|width:100px;][my caption]</code>.  If no grouping is being used, then the <code>|</code> is still used and the format would be <code>lightmodal[|width:100px;]</code>.  The properties should all be of the format "property: value;" - note the closing semi-colon.  If no properties are set, then the default width and height of 400px will be used. See below for more detailed examples.</p>

<p>Basic example:<br />
<code>
&lt;a href="search.php" rel="lightmodal"&gt;Search&lt;/a&gt;
</code></p>

<p>Basic example with caption:<br />
<code>
&lt;a href="search.php" rel="lightmodal[][my caption]"&gt;Search&lt;/a&gt;
</code></p>

<p>Grouped example:<br />
<code>
&lt;a href="search.php" rel="lightmodal[search]"&gt;Search&lt;/a&gt;<br />
&lt;a href="search.php?status=1" rel="lightmodal[search][published]"&gt;Search published content&lt;/a&gt;
Stella Power's avatar
Stella Power committed
</code></p>

<p>Controlling modal property example:<br />
<code>
&lt;a href="search.php" rel="lightmodal[|width:400px; height:300px; scrolling: auto;]"&gt;Search&lt;/a&gt;
</code></p>

<p>Controlling modal property when grouped example:<br />
<code>
&lt;a href="search.php" rel="lightmodal[search|width:400px; height:300px; scrolling: auto;]"&gt;Search&lt;/a&gt;<br />
&lt;a href="search.php?status=1" rel="lightmodal[search|width:400px; height:300px;][Search published]"&gt;Search published content&lt;/a&gt;<br />
&lt;a href="search.php?status=0" rel="lightmodal[search|width:400px; height:300px;][Search Unpublished]"&gt;Search unpublished content&lt;/a&gt;
</code></p>


Stella Power's avatar
Stella Power committed
<h3>Keyboard Shortcuts</h3>
<table border=0>
<tr><td>Close Lightbox</td><td>x</td></tr>
<tr><td></td><td>o</td></tr>
<tr><td></td><td>c</td></tr>
<tr><td></td><td>ESC</td></tr>

<tr><td>Previous Image</td><td>p</td></tr>
<tr><td></td><td>Left Arrow</td></tr>

<tr><td>Next Image</td><td>n</td></tr>
<tr><td></td><td>Right Arrow</td></tr>

<tr><td>Toggle Zoom</td><td>z (not available in slideshow)</td></tr>

<tr><td>Toggle Play / Pause</td><td>Spacebar (slideshow only)</td></tr>
</table>

<p>Not all of the keyboard shortcuts work in the Opera browser, for example "z" for toggling the zoom and "spacebar" for toggling play / pause in slideshows.  This can be overcome by updating your shortcut settings in the Opera preferences editor.</p>
');
Stella Power's avatar
Stella Power committed
/**
 * Implementation of hook_perm().
Stella Power's avatar
Stella Power committed
function lightbox2_perm() {
  return array('administer lightbox2', 'download original image');
Stella Power's avatar
Stella Power committed
/**
 * Implementation of hook_menu().
Stella Power's avatar
Stella Power committed
function lightbox2_menu() {
Stella Power's avatar
Stella Power committed
  $items = array();

Stella Power's avatar
Stella Power committed
  $items['admin/settings/lightbox2'] = array(
    'title' => 'Lightbox2',
    'description' => 'Allows the user to configure the lightbox2 settings',
    'file' => 'lightbox2.admin.inc',
    'page callback' => 'lightbox2_settings_page',
    'access callback' => 'user_access',
    'access arguments' => array('administer lightbox2'),
  );
  $items['admin/settings/lightbox2/general'] = array(
    'title' => 'General',
    'description' => 'Allows the user to configure the lightbox2 settings',
    'file' => 'lightbox2.admin.inc',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('lightbox2_general_settings_form'),
    'access callback' => 'user_access',
    'access arguments' => array('administer lightbox2'),
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => 0,
  );
  $items['admin/settings/lightbox2/slideshow'] = array(
    'title' => 'Slideshow',
    'description' => 'Allows the user to configure the lightbox2 slideshow functionality',
    'file' => 'lightbox2.admin.inc',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('lightbox2_slideshow_settings_form'),
    'access callback' => 'user_access',
    'access arguments' => array('administer lightbox2'),
    'type' => MENU_LOCAL_TASK,
    'weight' => 1,
  );
  $items['admin/settings/lightbox2/html_content'] = array(
    'title' => 'HTML Content',
    'file' => 'lightbox2.admin.inc',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('lightbox2_iframe_settings_form'),
    'access callback' => 'user_access',
    'access arguments' => array('administer lightbox2'),
    'description' => 'Allows the user to configure the lightbox2 HTML content functionality.',
    'type' => MENU_LOCAL_TASK,
    'weight' => 2,
  );
  $items['admin/settings/lightbox2/automatic'] = array(
    'title' => 'Automatic image handling',
    'description' => 'Allows the user to configure the lightbox2 automatic image handling settings',
    'file' => 'lightbox2.admin.inc',
Stella Power's avatar
Stella Power committed
    'page callback' => 'drupal_get_form',
    'page arguments' => array('lightbox2_auto_image_handling_settings_form'),
Stella Power's avatar
Stella Power committed
    'access callback' => 'user_access',
    'access arguments' => array('administer lightbox2'),
    'type' => MENU_LOCAL_TASK,
Stella Power's avatar
Stella Power committed
  );
  if (module_exists('emfield') && module_exists('emvideo')) {
    $items['video-cck/lightbox2'] = array(
      'page callback' => 'lightbox2_emvideo',
      'access callback' => 'user_access',
      'access arguments' => array('access content'),
      'type' => MENU_CALLBACK,
    );
  }
  if (module_exists('acidfree') && module_exists('video')) {
    $items['node/%nid/lightframevideo'] = array(
      'page callback' => 'lightbox2_acidfree_video',
      'page arguments' => array(1),
      'access callback' => 'user_access',
      'access arguments' => array('play video'),
  $items['user/login/lightbox2'] = array(
    'title' => 'Login',
    'page callback' => 'lightbox2_login',
    'access callback' => 'user_is_anonymous',
    'type' => MENU_CALLBACK,
  );
  $items['contact/lightbox2'] = array(
    'title' => 'Contact',
    'page callback' => 'lightbox2_contact',
    'access arguments' => array('access site-wide contact form'),
    'type' => MENU_CALLBACK,
  );
Stella Power's avatar
Stella Power committed
  return $items;
}

 * Implementation of hook_init().
  if (lightbox2_exclude_these_paths() != 1) {
 * Implementation of hook_filter_tips().
function lightbox2_filter_tips($delta, $format, $long = FALSE) {
      return t('Image links with \'rel="lightbox"\' in the &lt;a&gt; tag will appear in a Lightbox when clicked on.');
    }
    else {
      $output = '<p>'. t('To add a lightbox to your images, add rel="lightbox" attribute to any link tag to activate the lightbox. For example:') .'</p>';
      $output .= '<p>'. t('<code>&lt;a href="image-1.jpg" rel="lightbox"&gt;image #1&lt;/a&gt;</code>') .'</p>';
      $output .= '<p>'. t('<code>&lt;a href="image-1.jpg" rel="lightbox[][my caption]"&gt;image #1&lt;/a&gt;</code>') .'</p>';
Stella Power's avatar
Stella Power committed
      $output .= '<p>'. t('To show a caption either use the title attribute or put in the second set of square brackets of the rel attribute.') .'</p>';
      $output .= '<p>'. t('If you have a set of related images that you would like to group, then you will need to include a group name between square brackets in the rel attribute. For example:') .'</p>';
      $output .= '<p>'. t('<code>&lt;a href="image-1.jpg" rel="lightbox[roadtrip]"&gt;image #1&lt;/a&gt;<br /> &lt;a href="image-2.jpg" rel="lightbox[roadtrip][caption 2]"&gt;image #2&lt;/a&gt;<br /> &lt;a href="image-3.jpg" rel="lightbox[roadtrip][caption 3]"&gt;image #3&lt;/a&gt;<br /> </code>') .'</p>';
      $output .= '<p>'. t('There are no limits to the number of image sets per page or how many images are allowed in each set.') .'</p>';
      $output .= '<p>'. t('If you wish to turn the caption into a link, format your caption in the following way:') .'</p>';
      $output .= '<p>'. t('<code>&lt;a href="image-1.jpg" rel=\'lightbox[][&lt;a href="http://www.yourlink.com"&gt;View Image Details&lt;/a&gt;]\' &gt;image #1&lt;/a&gt;</code>') .'</p>';
  elseif ($delta == 1) {
    return t('Image links from G2 are formatted for use with Lightbox2');
  elseif ($delta == 2) {
Stella Power's avatar
Stella Power committed
    if (!$long) {
      return t('Image links with \'rel="lightshow"\' in the &lt;a&gt; tag will appear in a Lightbox slideshow when clicked on.');
    }
    else {
      $output = '<p>'. t('To add a lightbox slideshow to your images, add rel="lightshow[slideshowname][slide caption]" attribute to any link tag to activate the slideshow. For example:') .'</p>';
Stella Power's avatar
Stella Power committed
      $output .= '<p>'. t('<code>&lt;a href="image-1.jpg" rel="lightshow[show1]"&gt;image #1&lt;/a&gt;<br /> &lt;a href="image-2.jpg" rel="lightshow[show1]"&gt;image #2&lt;/a&gt;<br /> &lt;a href="image-3.jpg" rel="lightshow[show1]"&gt;image #3&lt;/a&gt;<br /> </code>') .'</p>';
      $output .= '<p>'. t('The title attribute in the link tag is optional. The addition of this attribute enables the display of a caption with the image displayed in the lightbox.') .'</p>';
      $output .= '<p>'. t('There are no limits to the number of slideshow image sets per page or how many images are allowed in each slideshow.') .'</p>';
      $output .= '<p>'. t('If you wish to turn the caption into a link, format your caption in the following way:') .'</p>';
      $output .= '<p>'. t('<code>&lt;a href="image-1.jpg" rel=\'lightshow[show1][&lt;a href="http://www.yourlink.com"&gt;View Image Details&lt;/a&gt;]\'&gt;image #1&lt;/a&gt;</code>') .'</p>';
Stella Power's avatar
Stella Power committed
      return $output;
    }
  }
  elseif ($delta == 3) {
Stella Power's avatar
Stella Power committed
    if (!$long) {
      return t('Links to HTML content with \'rel="lightframe"\' in the &lt;a&gt; tag will appear in a Lightbox when clicked on.');
    }
    else {
      $output = '<p>'. t('It\'s possible to show webpage content in the lightbox, using iframes.  In this case the "rel" attribute should be set to "lightframe".  Again it\'s possible to group the content, (e.g. <code>lightframe[search][caption]</code>) but in addition to that, it\'s possible to control some of the iframe properties.  It\'s possible to set the "width", "height" and "scrolling" properties of the iframe.  The properties are separated from the group name by a <code>|</code>, for example <code>lightframe[search|width:100px;][caption]</code>.  If no grouping is being used, then the <code>|</code> is still used and the format would be <code>lightframe[|width:100px;]</code>.  The properties should all be of the format "property: value;" - note the closing semi-colon.  If no iframe properties are set, then the default width and height of 400px will be used.  See below for more detailed examples.') .'</p>';
Stella Power's avatar
Stella Power committed
      $output .= '<p>'. t('Basic example:') .'<br />';
      $output .= t('<code>&lt;a href=&quot;http://www.google.com&quot; rel=&quot;lightframe&quot;&gt;Search google&lt;/a&gt;</code>') .'</p>';
      $output .= '<p>'. t('Grouped example:') .'<br />';
      $output .= t('<code>&lt;a href=&quot;http://www.google.com&quot; rel=&quot;lightframe[search][caption]&quot;&gt;Search google&lt;/a&gt;<br />&lt;a href=&quot;http://www.yahoo.com&quot; rel=&quot;lightframe[search]&quot;&gt;Search yahoo&lt;/a&gt;</code>') .'</p>';
Stella Power's avatar
Stella Power committed

      $output .= '<p>'. t('Controlling iframe property example:') .'<br />';
      $output .= t('<code>&lt;a href=&quot;http://www.google.com&quot; rel=&quot;lightframe[|width:400px; height:300px; scrolling: auto;][caption]&quot;&gt;Search google&lt;/a&gt;</code>') .'</p>';
Stella Power's avatar
Stella Power committed
      $output .= '<p>'. t('Controlling iframe property when grouped example:') .'<br />';
      $output .= t('<code>&lt;a href=&quot;http://www.google.com&quot; rel=&quot;lightframe[search|width:400px; height:300px; scrolling: auto;]&quot;&gt;Search google&lt;/a&gt;<br />&lt;a href=&quot;http://www.yahoo.com&quot; rel=&quot;lightframe[search|width:400px; height:300px;]&quot;&gt;Search yahoo&lt;/a&gt;</code>') .'</p>';

      return $output;
    }
  }
  elseif ($delta == 4) {
    if (!$long) {
      return t('Links to video content with \'rel="lightvideo"\' in the &lt;a&gt; tag will appear in a Lightbox when clicked on.');
    }
    else {
      $output = '<p>'. t('It\'s possible to show video content in the lightbox.  In this case the "rel" attribute should be set to <code>lightvideo</code>.  It\'s not possible to group videos but it is possible to control the size of the lightbox by setting the "width" and "height" properties.  The properties can be configured like <code>lightvideo[width:300px; height: 200px;][caption]</code>.  The properties should all be of the format "property: value;" - note the closing semi-colon.  If no properties are set, then the default width and height of 400px will be used.  See below for more detailed examples.') .'</p>';
      $output .= '<p>'. t('Basic example:') .'<br />';
      $output .= t('<code>&lt;a href=&quot;http://video.google.com/videoplay?docid=1811233136844420765&quot; rel=&quot;lightvideo&quot;&gt;Google video example - default size&lt;/a&gt;</code>') .'</p>';
      $output .= '<p>'. t('Controlling lightbox size example:') .'<br />';
      $output .= t('<code>&lt;a href=&quot;http://video.google.com/videoplay?docid=1811233136844420765&quot; rel=&quot;lightvideo[width:400px; height:300px;][caption]&quot;&gt;Google video example - custom size&lt;/a&gt;</code>') .'</p>';
      $output .= '<p>'. t('Supported video formats include asx, wmv, mov and swf.  A number of online video providers are also supported, including YouTube and Google Video.  For a full list of the current supported video providers please see the documentation on drupal.org.') .'</p>';
      return $output;
    }
  }
  elseif ($delta == 5) {
    if (!$long) {
      return t('Links to inline or modal content with \'rel="lightmodal"\' in the &lt;a&gt; tag will appear in a Lightbox when clicked on.');
    }
    else {
      $output = '<p>'. t('It\'s possible to show HTML snippets in the lightbox, that is on the same domain.  In this case the "rel" attribute should be set to "lightmodal".  Again it\'s possible to group the content, (e.g. <code>lightmodal[group][caption]</code>) but in addition to that, it\'s possible to control some of the modal properties.  It\'s possible to set the "width", "height" and "scrolling" properties of the modal.  The properties are separated from the group name by a <code>|</code>, for example <code>lightmodal[group|width:100px;][caption]</code>.  If no grouping is being used, then the <code>|</code> is still used and the format would be <code>lightmodal[|width:100px;]</code>.  The properties should all be of the format "property: value;" - note the closing semi-colon.  If no modal properties are set, then the default width and height of 400px will be used.  See below for more detailed examples.') .'</p>';
      $output .= '<p>'. t('Basic example:') .'<br />';
      $output .= t('<code>&lt;a href=&quot;search.php&quot; rel=&quot;lightmodal&quot;&gt;Search&lt;/a&gt;</code>') .'</p>';
      $output .= '<p>'. t('Grouped example:') .'<br />';
      $output .= t('<code>&lt;a href=&quot;search.php&quot; rel=&quot;lightmodal[search][caption 1]&quot;&gt;Search&lt;/a&gt;<br />&lt;a href=&quot;search.php?status=1&quot; rel=&quot;lightmodal[search]&quot;&gt;Search published&lt;/a&gt;</code>') .'</p>';

      $output .= '<p>'. t('Controlling modal property example:') .'<br />';
      $output .= t('<code>&lt;a href=&quot;search.php&quot; rel=&quot;lightmodal[|width:400px; height:300px; scrolling: auto;][caption]&quot;&gt;Search&lt;/a&gt;</code>') .'</p>';
      $output .= '<p>'. t('Controlling modal property when grouped example:') .'<br />';
      $output .= t('<code>&lt;a href=&quot;search.php&quot; rel=&quot;lightmodal[search|width:400px; height:300px; scrolling: auto;]&quot;&gt;Search&lt;/a&gt;<br />&lt;a href=&quot;search.php?status=1&quot; rel=&quot;lightmodal[search|width:400px; height:300px;]&quot;&gt;Search published&lt;/a&gt;</code>') .'</p>';

      return $output;
    }
  }
Stella Power's avatar
Stella Power committed

/**
 * Implementation of hook_filter().
 */
function lightbox2_filter($op, $delta = 0, $format = -1, $text = '') {
  switch ($op) {
    case 'list':
Stella Power's avatar
Stella Power committed
      return array(
        0 => t('Lightbox filter'),
        1 => t('Lightbox G2 filter'),
        2 => t('Lightbox slideshow filter'),
        3 => t('Lightbox iframe filter'),
        4 => t('Lightbox video filter'),
        5 => t('Lightbox modal filter'),
        6 => t('Disable Lightbox iframe filter'),
Stella Power's avatar
Stella Power committed
      );
Stella Power's avatar
Stella Power committed
      if ($delta == 0) {
        return t('Image links with \'rel="lightbox"\' in the &lt;a&gt; tag will appear in a Lightbox when clicked on.');
      }
      elseif ($delta == 1) {
        return t('Turns g2_filter links into Lightbox2 appropriate links');
      elseif ($delta == 2) {
Stella Power's avatar
Stella Power committed
        return t('Image links with \'rel="lightshow"\' in the &lt;a&gt; tag will appear in a Lightbox slideshow when clicked on.');
      }
      elseif ($delta == 3) {
Stella Power's avatar
Stella Power committed
        return t('Links to HTML content with \'rel="lightframe"\' in the &lt;a&gt; tag will appear in a Lightbox when clicked on.');
      elseif ($delta == 4) {
        return t('Links to video content with \'rel="lightvideo"\' in the &lt;a&gt; tag will appear in a Lightbox when clicked on.');
      }
      elseif ($delta == 5) {
        return t('Links to inline or modal content with \'rel="lightmodal"\' in the &lt;a&gt; tag will appear in a Lightbox when clicked on.');
      }
      elseif ($delta == 6) {
        return t('It\'s possible to show webpage content in the lightbox, using iframes.  In this case the "rel" attribute should be set to "lightframe".  However, users can do this without any filters to be enabled.  To prevent users from adding iframes to the site in this manner, then please enable this option.');
Stella Power's avatar
Stella Power committed
        $text = ' '. $text .' ';
        $text = preg_replace('/ShowItem/', 'DownloadItem', $text);
        $text = preg_replace('/src="/', 'rel="lightbox" src="', $text);
        $text = drupal_substr($text, 1, -1);
      elseif ($delta == 6) {
        $text = preg_replace('/<a([^>]*?)(rel=[\'"]*lightframe[\'"]*)([^>]*?)>/i', '<a\1\3>', $text);
      }
 * Provide links to the CSS stylesheet and JS file associated with
 * this module.
 */
function lightbox2_add_files() {
  static $already_added = FALSE;
  if ($already_added) {
    return; // Don't add the JavaScript and CSS multiple times.
  }
  $already_added = TRUE;
  // Load required js and css files.
  $path = drupal_get_path('module', 'lightbox2');
  $inline_image_handler = variable_get('lightbox2_inline', 0);
  $flickr_image_handler = variable_get('lightbox2_flickr', 0);
  $gallery2_block_handler = variable_get('lightbox2_gallery2_blocks', 0);
  $image_assist_handler = variable_get('lightbox2_image_assist_custom', 0);
  $image_node_handler = variable_get('lightbox2_image_node', 0);

  $custom_class_handler = 0;
  switch (variable_get('lightbox2_custom_class_handler', 0)) {
    case 1:
      $custom_class_handler = 'lightbox_ungrouped';
      break;
    case 2:
      $custom_class_handler = 'lightbox';
      break;
    case 3:
      $custom_class_handler = 'lightshow';
      break;
    case 4:
      $custom_class_handler = 'lightframe_ungrouped';
      break;
    case 5:
      $custom_class_handler = 'lightframe';
      break;
  }

  // Set the list of image classes to format urls for.
  $trigger_lightbox_classes = '';
  $trigger_lightbox_group_classes = '';
  $trigger_slideshow_classes = '';
  $trigger_lightframe_classes = '';
  $trigger_lightframe_group_classes = '';
  switch ($inline_image_handler) {
    case 1:
      $trigger_lightbox_classes .= 'img.inline,';
      $trigger_lightbox_group_classes .= 'img.inline,';
      $trigger_slideshow_classes .= 'img.inline,';
      break;
    case 4:
      $trigger_lightframe_classes .= 'img.inline,';
      break;
    case 5:
      $trigger_lightframe_group_classes .= 'img.inline,';
  switch ($flickr_image_handler) {
    case 1:
      $trigger_lightbox_classes .= 'img.flickr-photo-img,img.flickr-photoset-img,';
      $trigger_lightbox_group_classes .= 'img.flickr-photo-img,img.flickr-photoset-img,';
      $trigger_slideshow_classes .= 'img.flickr-photo-img,img.flickr-photoset-img,';
      break;
    case 4:
      $trigger_lightframe_classes .= 'img.flickr-photo-img,img.flickr-photoset-img,';
      break;
    case 5:
      $trigger_lightframe_group_classes .= 'img.flickr-photo-img,img.flickr-photoset-img,';
  // Gallery2 block images.
  switch ($gallery2_block_handler) {
    case 1:
      $trigger_lightbox_classes .= 'img.ImageFrame_image,img.ImageFrame_none,';
      $trigger_lightbox_group_classes .= 'img.ImageFrame_image,img.ImageFrame_none,';
      $trigger_slideshow_classes .= 'img.ImageFrame_image,img.ImageFrame_none,';
      break;
    case 4:
      $trigger_lightframe_classes .= 'img.ImageFrame_image,img.ImageFrame_none,';
      break;
    case 5:
      $trigger_lightframe_group_classes .= 'img.ImageFrame_image,img.ImageFrame_none,';
  switch ($image_assist_handler) {
    case 1:
      $trigger_lightbox_classes .= 'img.image-img_assist_custom,';
      $trigger_lightbox_group_classes .= 'img.image-img_assist_custom,';
      $trigger_slideshow_classes .= 'img.image-img_assist_custom,';
      break;
    case 4:
      $trigger_lightframe_classes .= 'img.image-img_assist_custom,';
      break;
    case 5:
      $trigger_lightframe_group_classes .= 'img.image-img_assist_custom,';
    $trigger_sizes = variable_get('lightbox2_trigger_image_size', array('thumbnail'));
    usort($trigger_sizes, "sort_by_length");
      $triggers = "img.$size, img.image-$size,";
        $triggers = "img._original, img.image-_original,";
      switch ($image_node_handler) {
        case 1:
          $trigger_lightbox_classes .= $triggers;
          break;
        case 2:
          $trigger_lightbox_group_classes .= $triggers;
          break;
        case 3:
          $trigger_slideshow_classes .= $triggers;
          break;
        case 4:
          $trigger_lightframe_classes .= $triggers;
          break;
        case 5:
          $trigger_lightframe_group_classes .= $triggers;
          break;
  // Custom images.
  $custom_triggers = variable_get('lightbox2_custom_trigger_classes', '');
  if ($custom_class_handler && !empty($custom_triggers)) {
    $trigger_classes = preg_split("/(\r\n|\n)/", $custom_triggers);
    foreach ($trigger_classes as $class) {
      if (!empty($class)) {
        $custom_trigger_classes .= "img.$class,";
  $trigger_lightbox_classes = rtrim($trigger_lightbox_classes, ",");
  $trigger_lightbox_group_classes = rtrim($trigger_lightbox_group_classes, ",");
  $trigger_slideshow_classes = rtrim($trigger_slideshow_classes, ",");
  $trigger_lightframe_classes = rtrim($trigger_lightframe_classes, ",");
  $trigger_lightframe_group_classes = rtrim($trigger_lightframe_group_classes, ",");
  $custom_trigger_classes = rtrim($custom_trigger_classes, ",");
  $image_node_sizes = '('. rtrim($image_node_sizes, "|") .')';
  $enable_video = variable_get('lightbox2_enable_video', FALSE);
Stella Power's avatar
Stella Power committed
  $enable_login = $user->uid == 0 && variable_get('lightbox2_enable_login', FALSE);
  $enable_contact = module_exists('contact') && variable_get('lightbox2_enable_contact', FALSE) && user_access('access site-wide contact form');
  // Load the javascript settings.
    'rtl' => $language->direction,
    'file_path' => base_path() .'(\w\w/)'. file_directory_path(),
    'default_image' => base_path() . $path .'/images/brokenimage.jpg',
    'border_size' => variable_get('lightbox2_border_size', 10),
    'font_color' => variable_get('lightbox2_font_color', '000'),
    'box_color' => variable_get('lightbox2_box_color', 'fff'),
    'top_position' => variable_get('lightbox2_top_position', ''),
    'overlay_opacity' => variable_get('lightbox2_overlay_opacity', 0.8),
    'overlay_color' => variable_get('lightbox2_overlay_color', '000'),
    'disable_close_click' => variable_get('lightbox2_disable_close_click', TRUE),
    'resize_sequence' => variable_get('lightbox2_resize_sequence', 0),
    'resize_speed' => 1000 * variable_get('lightbox2_resize_speed', 0.4),
    'fade_in_speed' => 1000 * variable_get('lightbox2_fadein_speed', 0.4),
    'slide_down_speed' => 1000 * variable_get('lightbox2_slidedown_speed', 0.6),
    'use_alt_layout' => variable_get('lightbox2_use_alt_layout', FALSE),
    'disable_resize' => variable_get('lightbox2_disable_resize', FALSE),
    'disable_zoom' => variable_get('lightbox2_disable_zoom', FALSE),
    'force_show_nav' => variable_get('lightbox2_force_show_nav', FALSE),
    'loop_items' => variable_get('lightbox2_loop_items', FALSE),
Stella Power's avatar
Stella Power committed
    'node_link_text' => check_plain(variable_get('lightbox2_node_link_text', 'View Image Details')),
    'node_link_target' => variable_get('lightbox2_node_link_target', FALSE),
Stella Power's avatar
Stella Power committed
    'image_count' => check_plain(variable_get('lightbox2_image_count_str', 'Image !current of !total')),
    'video_count' => check_plain(variable_get('lightbox2_video_count_str', 'Video !current of !total')),
Stella Power's avatar
Stella Power committed
    'page_count' => check_plain(variable_get('lightbox2_page_count_str', 'Page !current of !total')),
    'lite_press_x_close' => t('press !x to close', array('!x' => '<a href="#" onclick="hideLightbox(); return FALSE;"><kbd>x</kbd></a>')),
    'download_link_text' => '',
Stella Power's avatar
Stella Power committed
    'enable_login' => $enable_login,
    'enable_contact' => $enable_contact,
    // Automatic image handling settings.
    'keys_close' => variable_get('lightbox2_keys_close', 'c x 27'),
    'keys_previous' => variable_get('lightbox2_keys_previous', 'p 37'),
    'keys_next' => variable_get('lightbox2_keys_next', 'n 39'),
    'keys_zoom' => variable_get('lightbox2_keys_zoom', 'z'),
    'keys_play_pause' => variable_get('lightbox2_keys_play_pause', '32'),
    'display_image_size' => variable_get('lightbox2_display_image_size', ''),
    'image_node_sizes' => $image_node_sizes,
    'trigger_lightbox_classes' => $trigger_lightbox_classes,
    'trigger_lightbox_group_classes' => $trigger_lightbox_group_classes,
    'trigger_slideshow_classes' => $trigger_slideshow_classes,
    'trigger_lightframe_classes' => $trigger_lightframe_classes,
    'trigger_lightframe_group_classes' => $trigger_lightframe_group_classes,
    'custom_class_handler' => $custom_class_handler,
    'custom_trigger_classes' => $custom_trigger_classes,
    'disable_for_gallery_lists' => variable_get('lightbox2_disable_nested_galleries', TRUE),
    'disable_for_acidfree_gallery_lists' => variable_get('lightbox2_disable_nested_acidfree_galleries', TRUE),
    'enable_acidfree_videos' => variable_get('lightbox2_enable_acidfree_videos', TRUE),
    // Slideshow settings.
    'slideshow_interval' => variable_get('lightbox2_slideshow_interval', 5) * 1000,
    'slideshow_automatic_start' => variable_get('lightbox2_slideshow_automatic_start', TRUE),
    'slideshow_automatic_exit' => variable_get('lightbox2_slideshow_automatic_exit', TRUE),
    'show_play_pause' => variable_get('lightbox2_slideshow_show_play_pause', TRUE),
    'pause_on_next_click' => variable_get('lightbox2_slideshow_pause_on_next_click', FALSE),
    'pause_on_previous_click' => variable_get('lightbox2_slideshow_pause_on_previous_click', TRUE),
    'loop_slides' => variable_get('lightbox2_loop_slides', FALSE),
    // Iframe settings.
    'iframe_width' => variable_get('lightbox2_default_frame_width', 600),
    'iframe_height' => variable_get('lightbox2_default_frame_height', 400),
    'iframe_border' => variable_get('lightbox2_frame_border', 1),
    'enable_video' => $enable_video,
  if ($enable_video) {
    $js_settings['flvPlayer'] = check_plain(variable_get('lightbox2_flv_player_path', '/flvplayer.swf'));
    $js_settings['flvFlashvars'] = check_plain(variable_get('lightbox2_flv_player_flashvars', ''));
  }

  // Only supply these if the user has the correct permissions.
  if (user_access('download original image') && user_access('view original images')) {
    $js_settings['download_link_text'] = check_plain(variable_get('lightbox2_download_link_text', 'Download Original'));
  }

  drupal_add_js(array('lightbox2' => $js_settings), 'setting');


Stella Power's avatar
Stella Power committed
  // Check where we should load the javascript files - header or footer.
  $js_location = variable_get('lightbox2_js_location', 'header');

  if (!variable_get('lightbox2_lite', FALSE)) {
Stella Power's avatar
Stella Power committed
    $css = $path .'/css/lightbox.css';
    if (variable_get('lightbox2_use_alt_layout', FALSE)) {
      $css = $path .'/css/lightbox_alt.css';
    }
    // Check to see if any automatic image handling options are enabled.
    if ($image_node_handler || $flickr_image_handler || $gallery2_block_handler || $inline_image_handler || $image_assist_handler || $custom_triggers != '') {
      drupal_add_js($path .'/js/auto_image_handling.js', 'module', $js_location);
    if (variable_get('lightbox2_enable_video', FALSE)) {
      drupal_add_js($path .'/js/lightbox_video.js', 'module', $js_location);
    }
Stella Power's avatar
Stella Power committed
    if ($enable_login || $enable_contact) {
      drupal_add_js($path .'/js/lightbox_modal.js', 'module', $js_location);
Stella Power's avatar
Stella Power committed
    drupal_add_js($path .'/js/lightbox.js', 'module', $js_location);
Stella Power's avatar
Stella Power committed
  }
Stella Power's avatar
Stella Power committed
    $css = $path .'/css/lightbox_lite.css';
Stella Power's avatar
Stella Power committed
    drupal_add_js($path .'/js/lightbox_lite.js', 'module', $js_location);
 * Implementation of hook_field_formatter_info().
 *
 * Add certain lightbox and imagecache formatters to CCK image fields if
 * the imagefield.module and the imagecache.module exist.  Add additional
 * formatters if emfield, emimage and/or emvideo modules exist.
function lightbox2_field_formatter_info() {
  $formatters = array();
  $lightbox = $slideshow = $iframe = array();
  // Handle imagefield and filefield images.
  if (module_exists('imagecache') && (module_exists('imagecache') || module_exists('filefield'))) {
    $rules = array();
    if (function_exists('imagecache_presets')) {
      $presets = imagecache_presets();
      foreach ($presets as $preset_id => $preset_info) {
        $rules[$preset_id] = $preset_info['presetname'];
      }
    }
    else {
      $rules = _imagecache_get_presets();
    }
    $iframe['imagefield__lightframe2__original__node'] = array(
      'label' => 'Lightbox2 iframe: original->node page',
      'field types' => array('image', 'filefield'),
    foreach ($rules as $ruleid => $view_rule) {
      $lightbox['imagefield__lightbox2__original__'. $view_rule] = array(
        'label' => 'Lightbox2: original->'. $view_rule,
        'field types' => array('image', 'filefield'),
      $lightbox['imagefield__lightbox2__'. $view_rule .'__original'] = array(
        'label' => 'Lightbox2: '. $view_rule .'->original',
        'field types' => array('image', 'filefield'),
      $slideshow['imagefield__lightshow2__original__'. $view_rule] = array(
        'label' => 'Lightbox2 slideshow: original->'. $view_rule,
        'field types' => array('image', 'filefield'),
      $slideshow['imagefield__lightshow2__'. $view_rule .'__original'] = array(
        'label' => 'Lightbox2 slideshow: '. $view_rule .'->original',
        'field types' => array('image', 'filefield'),
      $iframe['imagefield__lightframe2__'. $view_rule .'__node'] = array(
        'label' => 'Lightbox2 iframe: '. $view_rule .'->node page',
        'field types' => array('image', 'filefield'),
      foreach ($rules as $rid => $lightbox_rule) {
        $lightbox['imagefield__lightbox2__'. $view_rule .'__'. $lightbox_rule] = array(
          'label' => 'Lightbox2: '. $view_rule .'->'. $lightbox_rule,
          'field types' => array('image', 'filefield'),
        $slideshow['imagefield__lightshow2__'. $view_rule .'__'. $lightbox_rule] = array(
          'label' => 'Lightbox2 slideshow: '. $view_rule .'->'. $lightbox_rule,
          'field types' => array('image', 'filefield'),
    // Adding them now so they are in some sort of sensible order.
    $formatters = array_merge($lightbox, $slideshow, $iframe);
  if (module_exists('emfield') && module_exists('emimage')) {
    $formatters['emimage_lightbox2'] = array(
      'label' => t('Lightbox2: Image Thumbnail -> Original'),
      'field types' => array('emimage'),
    $formatters['emimage_lightshow2'] = array(
      'label' => t('Lightbox2 slideshow: Image Thumbnail -> Original'),
      'field types' => array('emimage'),
    $formatters['emimage_lightframe2'] = array(
      'label' => t('Lightbox2 iframe: Image Thumbnail -> Content'),
      'field types' => array('emimage'),
  if (variable_get('lightbox2_enable_video', FALSE) && module_exists('emfield') && module_exists('emvideo')) {
    $formatters['emvideo_lightvideo'] = array(
      'label' => t('Lightbox2: Image Thumbnail -> Full Size Video'),
      'field types' => array('emvideo'),
  if (module_exists('filefield')) {
    $formatters['filefield_lightframe'] = array(
      'label' => t('Lightbox2 iframe'),
      'field types' => array('filefield'),
  return $formatters;
Stella Power's avatar
Stella Power committed
/**
 * Implementation of hook_theme().
Stella Power's avatar
Stella Power committed
 */
function lightbox2_theme() {
  $theme = array(
    'lightbox2_image' => array(
      'arguments' => array('path' => NULL, 'alt' => '', 'title' => '', 'attributes' => array()),
      'file' => 'lightbox2.formatter.inc',
    // Emfield theme functions.
    'lightbox2_emimage' => array(
      'arguments' => array('field' => NULL, 'item' => NULL, 'formatter' => NULL, 'node' => NULL, 'args' => array()),
      'file' => 'lightbox2.formatter.inc',
    'lightbox2_formatter_emimage' => array(
      'arguments' => array('element' => NULL),
      'file' => 'lightbox2.formatter.inc',
    ),
    'lightbox2_formatter_emimage_lightbox2' => array(
      'arguments' => array('element' => NULL),
      'file' => 'lightbox2.formatter.inc',
      'function' => 'theme_lightbox2_formatter_emimage',
    ),
    'lightbox2_formatter_emimage_lightshow2' => array(
      'arguments' => array('element' => NULL),
      'file' => 'lightbox2.formatter.inc',
      'function' => 'theme_lightbox2_formatter_emimage',
    ),
    'lightbox2_formatter_emimage_lightframe2' => array(
      'arguments' => array('element' => NULL),
      'file' => 'lightbox2.formatter.inc',
      'function' => 'theme_lightbox2_formatter_emimage',
    ),
    'lightbox2_formatter_emvideo_lightvideo' => array(
      'arguments' => array('element' => NULL),
      'file' => 'lightbox2.formatter.inc',
    ),
    'lightbox2_emvideo' => array(
      'arguments' => array('field' => NULL, 'item' => NULL, 'formatter' => NULL, 'node' => NULL),
      'file' => 'lightbox2.formatter.inc',
    // Filefield theme functions.
    'lightbox2_formatter_filefield_lightframe' => array(
      'arguments' => array('element' => NULL),
      'file' => 'lightbox2.formatter.inc',
    ),
    'lightbox2_file_formatter_lightbox2_iframe' => array(
      'arguments' => array('file' => NULL, 'field' => NULL, 'file_formatter_settings' => NULL),
      'file' => 'lightbox2.formatter.inc',
    ),
    // Global imagecache + imagefield theme functions.
    'lightbox2_formatter_imagefield' => array(
      'arguments' => array('element' => NULL),
      'file' => 'lightbox2.formatter.inc',
    ),
    'imagefield_image_imagecache_lightbox2' => array(
      'arguments' => array('view_preset' => NULL, 'field_name' => NULL, 'item' => NULL, 'node' => NULL, 'rel' => 'lightbox', 'args' => array()),
      'file' => 'lightbox2.formatter.inc',
Stella Power's avatar
Stella Power committed
  );
  // Additional imagecache + imagefield theme functions, by preset.
  if (module_exists("imagecache")) {
    $theme['lightbox2_formatter_imagefield__lightframe2__original__node'] = array(
      'arguments' => array('element' => NULL),
      'function' => 'theme_lightbox2_formatter_imagefield',
      'file' => 'lightbox2.formatter.inc',
    );
    foreach (imagecache_presets() as $src) {
      $theme['lightbox2_formatter_imagefield__lightbox2__'. $src['presetname'] .'__original'] = array(
        'arguments' => array('element' => NULL),
        'function' => 'theme_lightbox2_formatter_imagefield',
        'file' => 'lightbox2.formatter.inc',
      );
      $theme['lightbox2_formatter_imagefield__lightshow2__'. $src['presetname'] .'__original'] = array(
        'arguments' => array('element' => NULL),
        'function' => 'theme_lightbox2_formatter_imagefield',
        'file' => 'lightbox2.formatter.inc',
      );
      $theme['lightbox2_formatter_imagefield__lightbox2__original__'. $src['presetname']] = array(
        'arguments' => array('element' => NULL),
        'function' => 'theme_lightbox2_formatter_imagefield',
        'file' => 'lightbox2.formatter.inc',
      );
      $theme['lightbox2_formatter_imagefield__lightshow2__original__'. $src['presetname']] = array(
        'arguments' => array('element' => NULL),
        'function' => 'theme_lightbox2_formatter_imagefield',
        'file' => 'lightbox2.formatter.inc',
      );
      $theme['lightbox2_formatter_imagefield__lightframe2__'. $src['presetname'] .'__node'] = array(
        'arguments' => array('element' => NULL),
        'function' => 'theme_lightbox2_formatter_imagefield',
        'file' => 'lightbox2.formatter.inc',
      );
      foreach (imagecache_presets() as $dest) {
        $theme['lightbox2_formatter_imagefield__lightbox2__'. $src['presetname'] .'__'. $dest['presetname']] = array(
          'arguments' => array('element' => NULL),
          'function' => 'theme_lightbox2_formatter_imagefield',
          'file' => 'lightbox2.formatter.inc',
        );
        $theme['lightbox2_formatter_imagefield__lightshow2__'. $src['presetname'] .'__'. $dest['presetname']] = array(
          'arguments' => array('element' => NULL),
          'function' => 'theme_lightbox2_formatter_imagefield',
          'file' => 'lightbox2.formatter.inc',
        );
      }
    }
  return $theme;
/**
 * Configures settings and outputs the video.
 *
 * @param nid
 *   The node id.
 * @param width
 *   The lightbox video width.
 * @param height
 *   The lightbox video height.
 * @param field_name
 *   The name of the cck field the video is contained in.
 * @param provider
 *   The name of the 3rd party video provider.
 * @param id
 *   The video id.
 */
function lightbox2_emvideo($nid, $width, $height, $field_name, $provider, $id) {
  $field = array();
  $field['widget']['video_width'] = $width;
  $field['widget']['video_height'] = $height;
  $field['widget']['video_autoplay'] = 1;
  $field['field_name'] = $field_name;
  $node = node_load($nid);
  $items = $node->$field_name;
  foreach ($items as $item) {
    if ($item['provider'] == $provider && $item['value'] == $id) {
      break;
    }
  }
  print theme('emvideo_video_video', $field, $item, 'video_video', $node);
/**
 * Return TRUE if current path is disabled for lightbox according to
 * lightbox2_page_list and lightbox2_page_init_action.
function lightbox2_exclude_these_paths() {
  $action = variable_get('lightbox2_page_init_action', 'page_disable');
  $page_list = variable_get('lightbox2_page_list', '');
    // Retrieve Drupal alias for the current path (if exists).
    $alias = drupal_get_path_alias($_GET['q']);

Stella Power's avatar
Stella Power committed
    if (drupal_match_path($_GET['q'], $page_list) || drupal_match_path($alias, $page_list)) {
      return ($action == 'page_disable' ? 1 : 0);
    }
  return ($action == 'page_disable' ? 0 : 1);
function lightbox2_preprocess_page(&$variables) {
  if (arg(0) != 'node' || arg(2) != 'lightbox2') {