Please login or register.

Login with username, password and session length
Advanced search  

News:

You need/want an older version of sNews ? Download an older/unsupported version here.

Pages: 1 2 [3] 4 5

Author Topic: Simple PHP gallery  (Read 34955 times)

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Simple PHP gallery
« Reply #30 on: April 14, 2007, 12:01:26 AM »

Cracked it. Thanks Bob! (You know I was only yanking your chain with that "undecipherable" shit, right? :) )
The solution to my problem was putting the substr part within the link, like so:
Quote
$strOutput .= '<a href="'.db('website').substr($entryName, 0, -4).'" title="'.$entryName.'"><img class="'.$imgClass.'" src="'.$dirPath.$entryName.'" alt="'.$entryName.'" /></a> ' . chr(10);
Hi-ho, hi-ho, back to the mill I go... [whistles wildly off key] :)
And it's no longer Friday the 13th! (here, where I am...)
« Last Edit: January 22, 2008, 09:00:23 PM by Keyrocks »
Logged

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
Simple PHP gallery
« Reply #31 on: April 14, 2007, 10:20:38 AM »

Mmm ... substr($entryName, 0, -4) ... this one will not work nice with .jpeg for example.

There is already following code line:
Code: [Select]
         $fileInfo = pathinfo( $dirPath . $entryName );It's purpose is to provide file related info out-of-the-box without any substr(...) and other string handling functions:
Code: [Select]
       // File extension :)
        $fileExtension = $fileInfo['extension'];

        // Extension length
        $extLength = strlen($fileExtension);

        // And finally .jpeg safe substr() usage  example
        $anotherEntryName = substr($entryName, 0, -($extLength-1));
Hope this might be handy.

Is it possible to see that gallery script in action somewhere? I still have it only in dev environment, kind of uninspiring to look at ;)
Logged

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Simple PHP gallery
« Reply #32 on: April 14, 2007, 02:56:51 PM »

thanks codetwist, that will come in handy when jpeg or other 4-char extension is being used (I changed the extensions array to not include jpeg for my personal project so for me substr -4 worked).

The gallery will hopefullly be online this weekend. I just have to finish a client project first. Gotta eat you know... ;)

I did try making use of the fileinfo early on in my attempts but being something of a php analphabet I only managed to break things...
Thanks for the help! I'll post a link when the gallery is online.

/* Edit -- $anotherEntryName = substr($entryName, 0, -$extLength); returns the entryName with the dot
What do I need to change so the dot is removed along with the extension? Ideas?
Logged

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
Simple PHP gallery
« Reply #33 on: April 14, 2007, 03:23:56 PM »

Good :)

May be You can come up with default version of css classes that would blend nicely in default snews layout used in distro? Then this version of gallery script could be published as finished addon ;)


P.S.
Ughhh ... that dot thing ... I forgot :) in substr should go -($extLength-1)
Logged

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Simple PHP gallery
« Reply #34 on: April 14, 2007, 04:19:29 PM »

Quote from: codetwist
substr should go -($extLength+1)
thanks Valdis, but that should be -($extLength-1), right? That's what works for me anyway. +1 puts out "filename.j" wheras -1 outputs the intended "filename". It's all fixed though, thanks. :)

As for default CSS classes ... don't know if that's necessary. The script is fairly clear that class names should be added to both $introImgClass and $thumbImgClass/$mainImgClass to get the best result. I use "big" for the big (intro) image, "main" for main images and "thm" for thumbnails. Others may have completely different preferences, if nothing else then for language purposes... If you do use default class names, make them self explanatory. And you still need the comment in the script code, about adding class names to both the script and in the CSS.
That's just my opinion though. ;)
Logged

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
Simple PHP gallery
« Reply #35 on: April 14, 2007, 04:30:58 PM »

Ughhh ... fixed that +-1 with what works  :)
Logged

piXelatedEmpire

  • MIA
  • ULTIMATE member
  • ******
  • Karma: 37
  • Posts: 1401
  • currently MIA
Simple PHP gallery
« Reply #36 on: April 16, 2007, 02:34:42 AM »

I'd be very interested to see the finished product smithy as I'd like to use something like this for my photogallery and templates secion also :)
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Simple PHP gallery
« Reply #37 on: April 16, 2007, 07:31:03 AM »

guys -- check out the post I just made in the site showcase forum. (Or follow this link for immediate access...)
Logged

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
Simple PHP gallery
« Reply #38 on: April 16, 2007, 07:58:25 AM »

Agent, I click the thumbs, and get taken to another page, instead of seeing the larger gallery image...

Is this as it should be?
Logged
Of all the things I have lost, it is my mind that I miss the most.

piXelatedEmpire

  • MIA
  • ULTIMATE member
  • ******
  • Karma: 37
  • Posts: 1401
  • currently MIA
Simple PHP gallery
« Reply #39 on: April 16, 2007, 08:02:18 AM »

ditto here.. when you click on the little thumbs that have 'Download' underneath them, you are directed to a demo of that template.

Perhaps this is as it should be, however, what is the point of the larger 'preview' of the templates?  perhaps its intention is that when the smaller thumbnails are moused over, the image should change to reflect the relevant template?  That at least is my understanding.

Using IE6 FWIW.
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Simple PHP gallery
« Reply #40 on: April 16, 2007, 09:11:56 AM »

yep, it's as it should be, preview images lead to live demo pages fully stacked with sNews ... so there is no real purpose for a 'larger preview' image other than perhaps showing off more of the design detail. But then, this is an earlybird version and I haven't worked all the little details yet ... user experience is probably the one part that is most lagging behind, next to content (hmm... the two single most important items of a web site! oops!) ;) I will most likely reduce the number of small thumbs to three per row so they can be bigger insize and thereby better remove the need for a big preview.

The big image in the front row is sort of a "featured template" spot so no, nothing is supposed to happen when you mouse over a smaller thumbnail, Pix. A tooltip pops up but that's it.

For a classic photo gallery you would absolutely link the thumbnails to larger versions, either through a Thickbox/Lightbox/Litebox/Greybox thingy or the old skool way. But the template site is not a photo gall, that's for another part of the site.

The big thing with exposing the templates site, at this early stage, here was to show off the gallery. Usage-wise it's as simple as can be: set a few parameters in the gallery script, include it in a page or article, then just add a bunch of images to the designated spot(s) and ... there it is. Only thing I haven't been able to figure out is how to actually get it to pick a specific image as intro image (the bigger version). I've tried everything I can think of but it still picks an image based on its own pref's it seems. No biggie though, it's so simple to use I can live with that little quirk... But as a best case scenario I'd like to be able to avoid duplicates if I can. Goes to user experience if nothing else...

All in all, the script is very good I'd say. Big thanks to mike and codetwist!
Logged

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
Simple PHP gallery
« Reply #41 on: April 16, 2007, 10:06:32 AM »

Can You post Your code here? It was supposed that by setting $introImage it's possible to specify big one:
Code: [Select]
//$useIntroImage = false; // If set to true then possible to have differently formatted intro image
$useIntroImage = true;
//$introImage    = '*.*'; // Used if set to specific file name
$introImage    = '*.*';
Looked into that old code ... it was supposed, but not finished that way as I moved to next version - there is bug in function that gets intro image. In following code section:
Code: [Select]
  if ( $imgName !== '*.*' ) {
      // Look for specified intro file
      if ( is_file( $dirPath . $imgName ) ) {
         $fileInfo = pathinfo( $dirPath . $entryName );
         if (is_image_extension( $fileInfo["extension"] )) {
            $strOutput = '<a href="'.db('website').'/'.$entryName.'" title="'.$entryName.'"><img '.$strImgClass.'src="'.$dirPath.$entryName.'" alt="'.$entryName.'" /></a>';
         }
      }
   }
add following right after 'if (... ) {' line :
Code: [Select]
$entryName = $imgName;Hope, this helps with intro.

P.S.
Site looks exciting, indeed ;)
« Last Edit: January 22, 2008, 09:01:16 PM by Keyrocks »
Logged

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Simple PHP gallery
« Reply #42 on: April 16, 2007, 06:41:43 PM »

Thanks, entryName = imgName fixed it. I s'pose I should have figured that one out but as noted everywhere else, I'm something of a php analphabet. You'll have to bear with me.... ;)

Meanwhile I've updated the modified gallery script in terms of UE by changing the thumbnail pix links to show larger versions with Thickbox 2 and the latest jquery version, and added a text link on the line below the image leading to the respective demo system. The intro image link still leads to the demo page as there's no need for a larger view (the intro image is only 7-8% smaller in size than the full size).

Using Thickbox creates a new problem though: if you click a thumbnail and look at the pretty picture and then click the "close" link or anywhere on the image to close the Thickbox, you get transported to the index page, not back to the showcase page. No idea how to fix that at the moment, short of making the showcase page "Home". I thought about implementing the jumpTo link generator (found elsewhere in this forum, mods section possibly) but that would mean for me to edit the thickbox.js code and, what with me being php analphabet and all, is likely to break ever'thang.

'twist -- I can PM you my modified gallery.php if you want to look at the mess I've made... ;)
Logged

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
Simple PHP gallery
« Reply #43 on: April 16, 2007, 10:50:25 PM »

Seems that there is no configuration for Thickbox - it's either works as is or it's back to hacking away at code :/

As for gallery code, please, PM it ;)
Logged

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Simple PHP gallery
« Reply #44 on: April 16, 2007, 11:49:48 PM »

PM'd
Logged
Pages: 1 2 [3] 4 5