whatever

WWW
UserLand
Radio UserLand Mike's Radio Blogifier

This is your blog on Radio... enter at your own disk!

Daily Link Monday, January 21, 2002

My rough-n-ready randomImage Macro!
I think I have it working now! >;]

whatever
Ok -- I was bored, so I made this random image macro. It's simple and not much in the way of scalability, but whaddya expect from me!!! I'll eventually rewrite it to use the <%radio.macros.imageRef%> instead of what I've done there, but anyway... if it interests you, here's what you do [or at least what I did]:
  1. Create a folder inside your images folder and name it "random"
  2. Place "JPG" files in there (it'll work with "GIF" files, but you'll have to modify the script) -- named "image001.jpg" up to "image040.jpg"
    [note: i used a cheesy little freeware proggy called batch thumbs to make mine].
  3. Save the following as "randomImage.txt" and place it in your macros folder:
    on randomPix () {
    	local (imgBase = "images/random/image");
    	local (imgRange = string.padWithZeros ((random (1,40)),3));
    	local (imgExt = ".jpg");
    	local (imgName = (imgBase + imgRange + imgExt));
    	local (blogUrl = radio.macros.weblogUrl ());
    	local  (rblogImg = blogUrl + imgName);
    	return ("<img src=\"" + rblogImg + "" align="left" hspace="10" vspace="10" alt="whatever">");
    		}
    
  4. Modify the script if you want to use another naming convention, or if you have more or fewer images, or you have more time than I do, or whatever.
  5. Call the macro using:
    <%randomPix ()%>
    
Reference:
http://docserver.userland.com/basic/random
http://docserver.userland.com/string/padWithZeros
11:41:20 PM  Permanent Link  

Rahoo! Radio now pings Weblogs.com for categories... scriptilicious! >;]
3:17:43 PM  Permanent Link  

Yeah! Now that's what I like to hear. (And don't forget those pesky "alt" attributes in the image tags!)
12:24:12 PM  Permanent Link  


© Copyright 2002 Mike Donellan.

Updated: 4/10/2002; 10:53:28 AM.


January 2002
Sun Mon Tue Wed Thu Fri Sat
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
Dec   Feb


Home

...testing 123...

Radio UserLand


Valid HTML 4.01!
Valid CSS!

Click to see the XML version of this web page. Click here to send an email to the editor of this weblog.