Lightbox plugin for Wordpress

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Wed Apr 24, 2013 12:19 pm

Lightbox plugin for Wordpress

Postby Sceamer » Wed Apr 24, 2013 12:26 pm

Hi, I'm new at PHP coding, and I've been asked to code a plugin for Wordpress, which will allow me to select an image to show, plus allowing me to embed HTML code from subscription forms, such as those provided by and .

From the plugins tab in wordpress, I should be able to choose also the size of the lightbox (in pixels).
The overall look of the lightbox should be close to this: (banner in the right)

I already found some code to work with, but it's not a plugin, it's just a PHP function;

Code: Select all

function lightbox_display($dir_to_search, $rel){
      $image_dir = $dir_to_search;
      $dir_to_search = scandir($dir_to_search);
      $image_exts = array('gif', 'jpg', 'jpeg', 'png');
      $excluded_filename = '_t';
         foreach ($dir_to_search as $image_file){
         $dot = strrpos($image_file, '.');
         $filename = substr($image_file, 0, $dot);
         $filetype = substr($image_file, $dot+1);
         $thumbnail_file = strrpos($filename, $excluded_filename);
            if ((!$thumbnail_file) and array_search($filetype, $image_exts) !== false){
echo "<a href='".$image_dir.$image_file."' rel='".$rel."'>
<img src='".$image_dir.$filename."_t.".$filetype."' alt='".$filename."' width='100' height='80' title=''/>

I know this code would be a start, but I would appreciate any help.

php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: Lightbox plugin for Wordpress

Postby johnj » Wed Apr 24, 2013 7:57 pm

Drupal has a light box plugin module. Read the code for that and it should give you "some" inspiration.

Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 5 guests