inserting random photo with caption

Discussion in 'HTML' started by carolyn, Dec 31, 2005.

  1. carolyn

    carolyn Guest

    I am looking for a script that can load a random photo or other graphic into
    a web page. The trick is that I would also like it to load a related
    caption with the image.

    I have found lots of scripts that will load random photos, and also ones
    that will load random text. I have not found any that can load text
    related to a random photo. I may have to hone my programming skills and
    merge some scripts to do what I would like, however I am hoping that
    someone already has done the work and is making it available to the world.

    Thanks for pointing me in the right direction!

    Carolyn

    ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
     
    carolyn, Dec 31, 2005
    #1
    1. Advertising

  2. carolyn

    Els Guest

    carolyn wrote:

    > I am looking for a script that can load a random photo or other graphic into
    > a web page. The trick is that I would also like it to load a related
    > caption with the image.
    >
    > I have found lots of scripts that will load random photos, and also ones
    > that will load random text. I have not found any that can load text
    > related to a random photo. I may have to hone my programming skills and
    > merge some scripts to do what I would like, however I am hoping that
    > someone already has done the work and is making it available to the world.
    >
    > Thanks for pointing me in the right direction!


    I'd say take the script that does the random text, and just add some
    text like "<img src="..." alt="..."> to it?

    --
    Els http://locusmeus.com/
    Sonhos vem. Sonhos vão. O resto é imperfeito.
    - Renato Russo -
     
    Els, Dec 31, 2005
    #2
    1. Advertising

  3. carolyn

    Sid Ismail Guest

    On Sat, 31 Dec 2005 15:47:44 +0100, Els <>
    wrote:

    : I'd say take the script that does the random text, and just add some
    : text like "<img src="..." alt="..."> to it?


    Yep, or include the text INSIDE the graphic with a graphics editor
    like PSP. :)

    Sid
     
    Sid Ismail, Dec 31, 2005
    #3
  4. carolyn

    carolyn Guest

    Sid Ismail wrote:

    > On Sat, 31 Dec 2005 15:47:44 +0100, Els <>
    > wrote:
    >
    > : I'd say take the script that does the random text, and just add some
    > : text like "<img src="..." alt="..."> to it?
    >
    >
    > Yep, or include the text INSIDE the graphic with a graphics editor
    > like PSP. :)
    >
    > Sid


    Thanks for the suggestion. I don't like graphical text. Those that don't
    see the graphic, for whatever reason, also won't see the text telling them
    what it is all about. I suppose they would see the alt text, but that may
    or may not duplicate the caption.

    ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
     
    carolyn, Dec 31, 2005
    #4
  5. carolyn

    carolyn Guest

    Els wrote:

    > carolyn wrote:
    >
    >> I am looking for a script that can load a random photo or other graphic
    >> into
    >> a web page. The trick is that I would also like it to load a related
    >> caption with the image.
    >>
    >> I have found lots of scripts that will load random photos, and also ones
    >> that will load random text. I have not found any that can load text
    >> related to a random photo. I may have to hone my programming skills and
    >> merge some scripts to do what I would like, however I am hoping that
    >> someone already has done the work and is making it available to the
    >> world.
    >>
    >> Thanks for pointing me in the right direction!

    >
    > I'd say take the script that does the random text, and just add some
    > text like "<img src="..." alt="..."> to it?
    >


    Thanks! I think I must have been asleep for the past few days. I kept on
    thinking about taking the graphic scripts and wondering how to add the
    text. Taking the text and adding the graphic looks very simple.
    Apparently too simple for me to come up with on my own. LOL

    Carolyn


    ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
     
    carolyn, Dec 31, 2005
    #5
  6. carolyn wrote:
    > Els wrote:
    >
    >
    >>carolyn wrote:
    >>
    >>
    >>>I am looking for a script that can load a random photo or other graphic
    >>>into
    >>>a web page. The trick is that I would also like it to load a related
    >>>caption with the image.
    >>>
    >>>I have found lots of scripts that will load random photos, and also ones
    >>>that will load random text. I have not found any that can load text
    >>>related to a random photo. I may have to hone my programming skills and
    >>>merge some scripts to do what I would like, however I am hoping that
    >>>someone already has done the work and is making it available to the
    >>>world.
    >>>
    >>>Thanks for pointing me in the right direction!

    >>
    >>I'd say take the script that does the random text, and just add some
    >>text like "<img src="..." alt="..."> to it?
    >>

    >
    >
    > Thanks! I think I must have been asleep for the past few days. I kept on
    > thinking about taking the graphic scripts and wondering how to add the
    > text. Taking the text and adding the graphic looks very simple.
    > Apparently too simple for me to come up with on my own. LOL
    >

    Seems like everyone may be missing what Carolyn is asking, if you want
    associated text with image that randomly selected, what you need is some
    sort of database. You do not need a real database a flat file table
    would do. How you implement it depends on whether client-side JavaScript:
    function Snapshot(src,text){
    this.src=src;
    this.text=text;
    }

    var snapshots=new Array;
    var i=0;
    snapshots[i++]=new Snapshot('someImg.jpg','My text about some image.');
    snapshots[i++]=new Snapshot('anotherImg.jpg','Text about another.');
    ....

    make a random function that picks a number between 0 and
    (snapshots.length-1)

    then another function to write in associated image src and text

    document.write('<img src="' + snapshots[randomNum].src + '">');
    document.write('<p>' + snapshots[randomNum].text+ '</p>');


    Perl, or PHP or other server-side scripting (which would be a far better
    solution)

    create a text flat-file database with text editor say, 'snapshot.txt':

    #image field [tab separator] text field
    someImg.jpg My text about some image.
    anotherImg.jpg Text about another.
    ....

    Have you script read the file 'snapshot.txt' into an array and like the
    JavaScript pick a random number then build page or the results (Perl
    show)...

    my $lastRec = $#snapshots;
    my $randomNum = RandomFunc($lastRec);
    my ($imgSrc, $imgText) = split("\t", $snapshots[$randomNum]);

    then build page as required...have fun!




    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Dec 31, 2005
    #6
  7. carolyn

    Rob McAninch Guest

    >>carolyn wrote:

    >>>I am looking for a script that can load a random photo or other graphic
    >>>into
    >>>a web page. The trick is that I would also like it to load a related
    >>>caption with the image.


    I have a little Perl script that will insert a random line from a
    text file. It's meant to be used as a SSI.
    http://rock13.com/webhelp/perl/

    That line can be whatever HTML you need to insert an image and
    accompanying text.


    --
    Rob McAninch
    http://rock13.com
     
    Rob McAninch, Dec 31, 2005
    #7
  8. carolyn

    carolyn Guest

    Rob McAninch wrote:

    >>>carolyn wrote:

    >
    >>>>I am looking for a script that can load a random photo or other graphic
    >>>>into
    >>>>a web page. The trick is that I would also like it to load a related
    >>>>caption with the image.

    >
    > I have a little Perl script that will insert a random line from a
    > text file. It's meant to be used as a SSI.
    > http://rock13.com/webhelp/perl/
    >
    > That line can be whatever HTML you need to insert an image and
    > accompanying text.
    >


    Thanks. I use SSI somewhat extensively, so it sounds good to me. You do
    have a couple link problems on your pages, which I just sent a couple
    emails you about.

    Carolyn

    ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
     
    carolyn, Jan 1, 2006
    #8
  9. carolyn

    dorayme Guest

    In article <>,
    carolyn <> wrote:

    > I am looking for a script that can load a random photo or other graphic into
    > a web page. The trick is that I would also like it to load a related
    > caption with the image.
    >
    > I have found lots of scripts that will load random photos, and also ones
    > that will load random text. I have not found any that can load text
    > related to a random photo. I may have to hone my programming skills and
    > merge some scripts to do what I would like, however I am hoping that
    > someone already has done the work and is making it available to the world.


    Had this problem myself once and wrote a whole lot of conditional
    (one for each pic) in the js. Basically I did this:

    In the head I put:

    <script language="JavaScript" type="text/javascript">
    <!-- Hide this script from old browsers
    var random = Math.random() ;
    var picnum = Math.round(random*9)+1;

    // End Hiding Here -->
    </script>

    In the place I wanted the pic, in the body of the html, I wrote:

    <script language="JavaScript" type="text/javascript">
    <!-- Hide this script from old browsers
    document.write('<a href=index.html><img src=pic'+picnum+'.jpg
    border=0></a>')
    document.write('</td><td>')

    if (picnum==1) {document.write("<blockquote>Site visit to a
    province in China to assess a plant for making waste plastic into
    synthetic diesel fuel, which was tested on the spot in an
    all-purpose vehicle</blockquote>")}

    if (picnum==2) {document.write("<blockquote>Client inspects
    operation of vortex in hydrocyclone wax melting tank during
    development stages using water<blockquote>")}

    etc etc


    // End Hiding Here -->
    </script>

    I named my pics like this so the conditionals could catch them:

    pic1.jpg
    pic2.jpg

    etc

    (I had about 12 pics)

    Amazing. All my own work and it will be laughed at by all and
    sundry no doubt as being a bit amateurish. but it worked as far
    as I and the client could test....

    dorayme
     
    dorayme, Jan 1, 2006
    #9
  10. carolyn wrote:
    > I am looking for a script that can load a random photo or other graphic into
    > a web page. The trick is that I would also like it to load a related
    > caption with the image.
    >
    > I have found lots of scripts that will load random photos, and also ones
    > that will load random text. I have not found any that can load text
    > related to a random photo. I may have to hone my programming skills and
    > merge some scripts to do what I would like, however I am hoping that
    > someone already has done the work and is making it available to the world.
    >
    > Thanks for pointing me in the right direction!
    >
    > Carolyn
    >
    > ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
    > http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    > ----= East and West-Coast Server Farms - Total Privacy via Encryption =----


    Hi Carolyn,

    I am doing something very similar to what you're trying to do on my
    website (see link below signature below). I created a PHP script to
    access a flat file in which the text is associated with the image.

    You mentioned something about the text being related to a random photo.
    Are you really looking to display the photos randomly, or in a
    particular order? In either case it should be fairly simple to implement.

    Happy New Year!

    --
    Chris Vancouver

    Increase hits to your website and earn e-gold - place
    your ad image in the Dynamic Masterpiece today!

    http://www.dynamicmasterpiece.com
     
    Chris Vancouver, Jan 2, 2006
    #10
  11. carolyn

    dorayme Guest

    In article
    <l%5uf.5135$>,
    Chris Vancouver <> wrote:

    > carolyn wrote:
    > > I am looking for a script that can load a random photo or other graphic
    > > into
    > > a web page. The trick is that I would also like it to load a related
    > > caption with the image.
    > >
    > > I have found lots of scripts that will load random photos, and also ones
    > > that will load random text. I have not found any that can load text
    > > related to a random photo. I may have to hone my programming skills and
    > > merge some scripts to do what I would like, however I am hoping that
    > > someone already has done the work and is making it available to the world.
    > >
    > > Thanks for pointing me in the right direction!
    > >
    > > Carolyn


    I told you, Carolyn, what I did and how it worked and included
    the simple head script and a snippet of the main body one. I
    mention to correct a minor mistake, I said I had about 12 pics. I
    had a bit less as can be seen from the head script.

    > >
    > > ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet
    > > News==----
    > > http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+
    > > Newsgroups
    > > ----= East and West-Coast Server Farms - Total Privacy via Encryption =----

    >
    > Hi Carolyn,
    >
    > I am doing something very similar to what you're trying to do on my
    > website (see link below signature below). I created a PHP script to
    > access a flat file in which the text is associated with the image.
    >


    > http://www.dynamicmasterpiece.com


    Where are these pics? They do not appear in my Safari?

    dorayme
     
    dorayme, Jan 2, 2006
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. RC
    Replies:
    2
    Views:
    506
    John M Deal
    Nov 24, 2004
  2. ©®
    Replies:
    4
    Views:
    3,492
    Jim Moe
    Feb 21, 2006
  3. globalrev
    Replies:
    4
    Views:
    815
    Gabriel Genellina
    Apr 20, 2008
  4. John
    Replies:
    7
    Views:
    656
  5. VK
    Replies:
    15
    Views:
    1,324
    Dr J R Stockton
    May 2, 2010
Loading...

Share This Page