Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #3720

Re: displaying random images with an appropriate caption

From Jerry Stuckle <jstucklex@attglobal.net>
Newsgroups comp.lang.php
Subject Re: displaying random images with an appropriate caption
Date 2011-11-08 22:51 -0500
Organization A noiseless patient Spider
Message-ID <j9ctcp$l3a$1@dont-email.me> (permalink)
References <327b7740-9dc9-41f0-8c4e-998c4318c9bb@13g2000prp.googlegroups.com>

Show all headers | View raw


On 11/8/2011 10:34 PM, paris2venice wrote:
> Is there any way to write something that will choose not just a random
> image but the random image and its caption as a pair?
>
> This is my code for my random images as it exists now but,
> unfortunately, it doesn't work very well if I don't have a caption
> with the photo (even if just to credit the photographer):
>
>
> <div style="float:right; width:363px;
>        margin: 1.0em 2.75em 1.0em 1.0em; padding: 0.25em;
>        text-align:center; background-color: #fff">
> <?php
>           $dir="/library/images/slideshow";
>           $images = array("$dir/farm-640x480.gif" ,
>                                  "$dir/ranch-640x480.gif" ,
>                            "$dir/plantation-640x480.gif");
>           $format='<img src="%s"
>                             class="rounded-corners"
>                             style="width:360px;height:270px" />';
>           printf("$format", $images[array_rand($images)]);
>           echo "\n";
> ?>
> </div>
>
> Thanks for any help and/or suggestions.

A better question is - how do you want to relate the caption to its 
picture?  Once you've decided how you want to relate them on your 
server, displaying the related caption is easy.

It could be a database... file name similarity... different 
directories... about anything you want.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

displaying random images with an appropriate caption paris2venice <paris2venice@gmail.com> - 2011-11-08 19:34 -0800
  Re: displaying random images with an appropriate caption Jerry Stuckle <jstucklex@attglobal.net> - 2011-11-08 22:51 -0500
    Re: displaying random images with an appropriate caption paris2venice <paris2venice@gmail.com> - 2011-11-08 19:54 -0800
      Re: displaying random images with an appropriate caption Denis McMahon <denismfmcmahon@gmail.com> - 2011-11-09 12:06 +0000
        Re: displaying random images with an appropriate caption paris2venice <paris2venice@gmail.com> - 2011-11-10 22:27 -0800
          Re: displaying random images with an appropriate caption Denis McMahon <denismfmcmahon@gmail.com> - 2011-11-11 10:50 +0000
  Re: displaying random images with an appropriate caption paris2venice <paris2venice@gmail.com> - 2011-11-08 19:39 -0800
    Re: displaying random images with an appropriate caption houghi <houghi@houghi.org.invalid> - 2011-11-09 08:51 +0100

csiph-web