inserting random photo with caption

C

carolyn

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
 
E

Els

carolyn said:
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?
 
S

Sid Ismail

: 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
 
C

carolyn

Sid said:
: 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.
 
C

carolyn

Els said:
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
 
J

Jonathan N. Little

carolyn said:
Els wrote:




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!
 
C

carolyn

Rob said:
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
 
D

dorayme

carolyn said:
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
 
C

Chris Vancouver

carolyn said:
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

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
 
D

dorayme

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.
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.

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

dorayme
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,044
Latest member
RonaldNen

Latest Threads

Top