bakunin has asked for the wisdom of the Perl Monks concerning the following question:

Hello all!

I'm working on a simple image gallery. No fancy stuff. Just CGI.pm + CSS.

The problem is the captions! I came up with a solution but it can be open to debate. You know, in an image gallery, there is an image and right below the image, there is its information.

what is the usual/efficient/best way of placing a caption below the image? Well, I thought of creating another set of TDs below the image TDs.

Then, I looked at http://gallery.sourceforge.net, those folks appear to apply a similar technique, though still it is a rather complicated gallery app.

20031020 Edit by Corion: Fixed link

Replies are listed 'Best First'.
Re: image captions in a gallery
by davido (Cardinal) on Oct 20, 2003 at 11:48 UTC
    What is your Perl question?

    You're asking an HTML question. Once you figure out your HTML solution you might use Perl to generate that HTML, but that doesn't make it a Perl question.

    If you get stuck on some Perl issue as you implement a script that outputs the HTML necessary to generate images with captions below them, let us know.

    As for figuring out your HTML issue, why not take a peek at the source-HTML for those pages that you admire most, and glean some ideas?


    Dave


    "If I had my life to do over again, I'd be a plumber." -- Albert Einstein
      What's up with the flames? You could just have written one short sentence to make your point. And it was not a non-Perl and dumb question.

      Ogla V. Sungutay
      Theoretical Physicist
Re: image captions in a gallery
by barrd (Canon) on Oct 20, 2003 at 14:00 UTC
    Hi bakunin,
    As davido points out above this is more a HTML question than perl but I'll bite anyway and try and help. You'll be wanting something not entirely unlike below yes?

    Image 1 Image 2 Image 3
    Caption 1 Caption 2 Caption 3

    Well to code a table like that you need HTML something like:

    <table width="100%" border="2" cellspacing="1" cellpadding="4"> <tr><td align="center"> <b>Image 1</b> </td><td align="center"> <b>Image 2</b> </td><td align="center"> <b>Image 3</b> </td></tr> <tr><td align="center"> Caption 1 </td><td align="center"> Caption 2 </td><td align="center"> Caption 3 </td></tr> </table>

    Obviously you can change the content of the tags to meet your requirements. Achieving this in perl is as always a TMTOWTDI scenario, but you probably want to be looking at CGI.pm. A quick heads up though, read the dox carefully as the tr tag using this system will give you results you didn't expect otherwise (hint: Tr).

    How you incorporate a loop to go through images placing them in table cells then matching the caption text is another topic you'll need to think about but hopefully the above will get you started down the road to success.

    Good luck and happy coding.

      Thank you for your nice reply barrd. I had already done what you have suggested.
        Hi again bakunin,
        Thank you for your nice reply barrd. I had already done what you have suggested.
        No problem, and thank you too.

        Heres another tip, if you haven't seen, used or tried HTML::Template I'd really recommend you do so. Since using it my life has improved about 1000%, and I mean that seriously. Theres a plethora of other modules that interact with it and you can do some really funky things. Basically it allows you to extract the HTML from your Perl code leaving both to do what they do best without lots of ugly code in your scripts. Have a look, you won't regret it.