Home
+ · sNews Development
+++ · [ADD-ON] galleries WIP

[ADD-ON] galleries WIP

posted in sNews Development | on 09.07.2008. 15:31

this is a WIP Gallery addon, maybe will turn into a mod,
i have added below the first part of the script with comments, and a link to download package with all file needed.

alian plant.jpg

alian plant.jpg
550 X 550

velvet.jpg

velvet.jpg
550 X 501

burned.jpg

burned.jpg
550 X 462

jons.jpg

jons.jpg
562 X 480

sunbath.jpg

sunbath.jpg
550 X 450

shout.jpg

shout.jpg
500 X 500

potato.jpg

potato.jpg
550 X 501

bird.jpg

bird.jpg
550 X 550


UPDATE: 16/07/2008

Thank you Vasile for advise with latest fix.


  <?php
 
/**
   *    Easy Galleries Script ::
   *    @ Moshe Gil Lemberger
   *    July 09 2008 ::
   *    email: mymgl@yahoo.com
   *    website: http://www.cms-zen.com
   
   *   FIX: code updated 16/07/08
   *   thank you vasile for advise 
   *   http://moriscanet.blogspot.com/
   */
   
// TAG TO CALL THE GALLERY
easyGal('gallery-dir','your-galleries-root-path','y','ibox');    

// easyGal function
function easyGal$gsef$groot=''$rel=''$styl='' ) {
    global 
$errors;
    
//////////////////////////////////
    # $gsef => name for gallery directory
    
$galName $gsef.'/';
    
# $tumbs => name for tumbs directory
    
$tumbs 'tumbs/';
    
# $larg => name for pictures source directory    
    
$larg 'larg/';
    
# $groot => name for ROOT galleries directory [ contain all galleries ]     , relation to document location
    
    //// 16/07/08 FIX: galleries_root closing slash was added to code.
    //// NOTE: No need for the closing slash in function parameter, 
    ////         just the name for your galleries_root.
    //// end FIX 16/07/08.
    
$galleries_root $groot!='' $groot.'/' "galleries_root/";
    
    
# $rel => Set this for PREV - NEXT link option (  'y' or empty ) 
    
$rel $rel!='y' 'lightbox' 'lightbox['.$gsef.']';
    
    
$gallery=$galleries_root.$galName;
    
$tumbdir=$gallery.$tumbs;
    
$largdir=$gallery.$larg;
    
      if (
is_dir($tumbdir)) {
          
$fd opendir($tumbdir);  
          
$images = array(); 
          while ((
$part = @readdir($fd)) == true) {  
              
clearstatcache();
              if ( 
eregi("(gif|jpg|png|jpeg)$",$part) ) {
                  
$images[] = $part
                } 
            }    
    
# here we echo the javascript and css for the gallery
    
echo '
            <script type="text/javascript" src="js/mootools.js"></script> 
            <script type="text/javascript" src="js/slimbox.js"></script>
            <link rel="stylesheet" href="css/slimbox.css" type="text/css" media="screen" />
            <link rel="stylesheet" href="css/ibox.css" type="text/css" media="screen" />
            <script type="text/javascript" src="js/egfx.js"></script>
        '
;
    
# end js
    
        
$so=sizeof($images);
        for (
$x=0$x<$so$x++) {
            
$imgName=$images[$x];
            
$tumbsrc $tumbdir.$imgName;
            
$imgsrc$largdir.$imgName;    
            
$title=$imgName;
            
$title=eregi_replace("(-|_)",' ',$title);
            list(
$width,$height)=getimagesize($imgsrc);
            echo 
'<div class="'.$styl.'">';
                echo 
'<a href="'.$imgsrc.'" rel="'.$rel.'" title="'.$title.'">';
                    echo 
'<img src="'.$tumbsrc.'" alt="'.$title.'" />';
                echo 
'</a>';        
            echo 
'<p><span>'.$title.'</span><br/>';
                echo 
$width .' X  '$height;
            echo 
'</p>';
            echo 
'</div>';
        }
    } else { 
            
$errors[] = $tumbdir.' is not a directory'
            return 
false
            } 
}
//////
    
?>  <?php
   
/*    
    USE: 
        copy files in css, js directories to your server ( corresponding dir )
        include this script ( will work on any php page or cms )
        
        - make ROOT directory for all your galleries,
                # ( Preset in the function as "galleries_root/" )
                # can be set as option in function parameters.
                # can be set different root for any call to the script.
                
        - inside the ROOT, 
                for each gallery you need a directory.
                    # this will be used as the first parameter in function call.
                
                inside, make 2 sub directories, 
                1 to hold the tumbs and 1 to hold the larg pictures,
                #(   Preset in the function as 'tumbs/'  and  'larg/'  ).
                # can be set as option in function parameters.
        
        call the function where ever you want to display the gallery.
        easyGal( 'GALLERY DIR NAME' , 'ROOT GALLERIES DIR' ,  ENTER 'y' OR LEAVE EMPTY , 'THE TUMB DIV STYLE/S (i use tag ibox )' )
        
        for include within the text area of article, use:
        [MOD] Function use in articles (snews1.6)  by philmoz.  location: http://snewscms.com/forum/index.php?topic=4583.0
    */
    
?>  


*** Download package here
this package packed with the mootools and slimbox js lib
Comments
writen by funlw65
on 2008-07-10 03:13:10
Moshe,
This looks great! I like it very much.
writen by moshe ••
on 2008-07-10 11:05:30
hey vasi, thank you :)
i will update very soon
with the script and how to use.

awesome day
writen by funlw65 •••
on 2008-07-11 18:57:13
Thank you Moshe, downloaded!
Awesome day!
writen by Philippe/Sven
on 2008-07-11 18:14:04
Hello from Paris to brothers Mo and Vasile.
writen by moshe ••
on 2008-07-12 17:06:28
hello from tel-aviv,
good to see you brother Sven :)

Vasile, if you have any problem with the script let me know.

awesome day my friends
writen by Nicu Alecu
on 2008-07-12 20:30:47
Great job! bothe with the pics and with the add-on.
writen by moshe ••
on 2008-07-12 20:47:32
hey Nicu Alecu :)
thank you.
writen by Poppoll
on 2008-11-22 03:46:01
Mosh,
I posted a solution on sNews (http://snewscms.com/forum/index.php?topic=7909.0)to have the pic names displayed at the bottom of the Highslide popup.
Thanks again for sharing this really great mod.
Poppoll
writen by moshe ••
on 2010-04-11 20:04:39
Quote from Poppoll
Mosh,
I posted a solution on sNews (http://snewscms.com/forum/index.php?topic=7909.0)to have the pic names displayed at the bottom of the Highslide popup.
Thanks again for sharing this really great mod.
Poppoll
Hi Poppol, thank you for solution, sharing feels good, to know it's being used is great. awesome night.
writen by sasha •
on 2010-01-29 08:25:31
how about making gallery with comments under each picture
writen by moshe ••
on 2010-01-30 20:16:26
sasha,
for this gallery addon to have comments for each photo
would need javascript comments script to interact with each
photo.