I’ve just put the finishing touches on the latest version of the Random Image Plugin that I originally released in the summer. This plugin will allow you to produce an <IMG> tag containing a randomly selected image from a folder of your choice on any wordpress page (or post if you allow php).
The two biggest features in this version are:
- Automatic discovery of your Wordpress Folder: One of the biggest barriers to entry for the non-technical folks who tried to use this plugin was a lack of knowledge (or access) for finding the physical path to the Wordpress installation. The plugin will now automatically detect and use this path.
CAVEAT: If you currently point your plugin at a folder which is outside of your wordpress installation, you will need to move that folder to use the v1.2.0+ versions of the plugin. - Scaling/Sizing of the Displayed Images: One of the most requested features from the first iteration of the plugin was the ability to resize or scale images to fit in a particular location. With older versions, if you wanted all the images to display at the same size or proportions then you needed to resize them all prior to uploading. Well this is no more! Now you can upload tons of randomly-sized images and the plugin will take care of the dirty work (including the calculation of just how much to scale-to-fit.
I’d like to take the opportunity to thank everyone who has downloaded the plugin, and particularly those who have taken the extra time to send me feedback. As of this release the plugin has been downloaded over 2,400 times which far exceeds anything I thought I would accomplish.
So give this plugin a shot, and let me know if it works out for you!
78 responses so far ↓
1 Wordpress Plugin: Random Image Selector | K's Weblog // Dec 9, 2007 at 1:27 am
[...] December 9, 2007: The Random Image Plugin has been updated! Please see the new post for updates on features, or to [...]
2 Laura // Dec 10, 2007 at 5:18 pm
I installed and loved this plugin a week ago, displaying random pictures in my sidebar (no widgets). Today my husband helped me to upgrade WordPress from 2.0.4 to 2.3.1. Now that I’m on the current version, I implemented the built-in sidebar widgets. I’ve verified that the plugin is working. I get random images when I put the code on a different page, but it no longer works in my sidebar. Help!
3 kdmurray // Dec 10, 2007 at 5:55 pm
Hi Laura,
When you activate widgets in Wordpress, everything in your static sidebar is ignored. If you turn off your widgets, the images should return, but you would lose the functionality of any new widgets that you’ve added.
The plugin doesn’t currently have “widget support”. I’m planning to add this feature in the next version, but I haven’t quite figured out when it will be released.
4 Laura // Dec 13, 2007 at 12:52 am
Hi,
Yup. Got that the regular sidebar goes away when widgets are used, and vise-versa. I want to use widgets, but I also want to use your nifty random image plugin.
Have my fingers crossed that you get it figured out soon. I really miss it!
5 Alex Leonard // Dec 13, 2007 at 6:13 pm
Hey there.
I came across this nifty plugin and am delighted as it’s been a great help on a project I’m doing for a non-profit organisation (the site’s not officially live yet, but you can look at it at http://www.gbv.ie/index.php).
I had one thing I thought I should mention. As I am using strict validation, all the image elements on the website must have an alt attribute.
I have adjusted the latest release of the plugin so that line 225 reads:
echo '';
I’m not sure that there’ll be a better way of getting a readable name in there, but as long as the filename is explanatory, then it should be beneficial.
6 Alex Leonard // Dec 13, 2007 at 6:14 pm
damn. I never know what word press comments are going to do to code lines…
em - maybe this:
`echo ”;`
or
echo '';
7 john // Dec 15, 2007 at 7:29 pm
can i put a link to any post with a single image ?
8 Carla // Dec 17, 2007 at 1:59 am
Hello. I am having some trouble getting this plugin to work for me and I am hoping you’ll be able to help.
I have installed and activated the plugin, and put the php code in the sidebar, but nothing appears at all.
I have filled out the options page to the best of my ability. I know I have #2 correct (http://www.MYDOMAIN.org/connect/wp-content/photos), but am not sure how to tell if #1 is right.
My installation of WP is in a folder called “connect” inside the root directory, but the index for it is in the root directory.
This part is automatically on the options page:
/usr/local/psa/home/vhosts/MYDOMAIN.ORG/httpdocs/connect/
And I have tried entering these in the box just to the right:
/wp-content/photos/
wp-content/photos/
I am not getting any error messages. I am using Firefox.
I know this is a long comment but I hope you can help me. Thank you very much!
9 kdmurray // Dec 17, 2007 at 5:37 pm
@Alex: Thanks for the comment and the email, this has been added to the next revision of the plugin.
@John: You can put a link around the entire tag right now, but there isn’t a way to link based on the image that comes up.
@Carla: The second option (wpcontent/photos/) should be working. If you can include a link to your site, I might be able to have a look and see what the path should be.
10 Carla // Dec 18, 2007 at 11:44 am
I gave up and used something else, but I’d still like to figure it out. Website’s very much “under construction.”
11 Ch-ch-ch-ch-Changes! | enreas // Dec 21, 2007 at 8:18 am
[...] Random Image Selector3. [...]
12 radiohode // Dec 31, 2007 at 12:11 pm
I’m using the 3K2 theme, where the background image in the header is defined in the style.css file. The code is:
#header {
padding: 0;
margin: 0;
position: relative;
height: 200px;
background:url(images/head.jpg) no-repeat #e6f7ff;
}
How can I use this plugin to change the background header image?
13 Michelle Sullivan // Jan 3, 2008 at 10:28 pm
Love it! Just got it working on my test site. A great added feature would be if you could match graphics with page and post ID’s - so have 124.jpg load when you’re on a page with that ID. That would be fantastic!
14 Lavado de cara // Jan 7, 2008 at 3:23 pm
[...] ya est
15 kdmurray // Jan 7, 2008 at 10:53 pm
@Michelle: Thanks for the feedback. I’ll add it to the “list of requested features” for future versions…
16 saffron // Jan 9, 2008 at 12:55 am
I was wondering if it’s possible to put several Random Image generators in 1 site - that each point to different image folders?
Would I need to upload several versions of the plugin or is there another way to do this?
Thanks
17 hizb // Jan 9, 2008 at 8:14 am
nice plugin - thx for the share
I could be very fancy to make it possible that the pictures were could be link to a specific site..
best regard,
Md - http://www.islamdk.dk
18 Michelle Sullivan // Jan 9, 2008 at 9:46 pm
Look forward to it. Site is now live and the random images really ‘make it’!
19 kdmurray // Jan 9, 2008 at 11:25 pm
@saffron: currently the plugin reads from one source. You’d need to make copies of it, and change some of the code.
@hizb: currently the plugin doesn’t support linking to specific sites. There has been several requests for this so I may take this on later this year.
20 Hasser // Jan 10, 2008 at 3:09 pm
Hey K!
Looks like a great plugin you’ve created here! My question is similar to Radiohode’s inquiry. I’d like to use the plugin to generate a random background for my entire frontpage.
I’m calling for my current background in the css right now:
body {
font-size: 62.5%; /* Resets 1em to 10px */
font-family: ‘Lucida Grande’, ‘Verdana’, ‘Arial’, ‘Sans-Serif’;
color: #fff;
text-align: left;
background-color: #000000; /* f26522 - original orange */
background-attachment: fixed;
background-image: url(http://www.hasservision.com/images/sunset_08-10-07.jpg);
background-repeat: no-repeat;
}
Is it possible to but the php code in the css, or do I need to create a separate php file?
Thanks again for your contribution!
-GK Hasser
21 kdmurray // Jan 10, 2008 at 10:01 pm
@Hasser: The because the plugin is applied with a PHP function, it cannot be called from a PHP file. You can rename your .css file to a .php file, and put functions in… but you’ll need to change all the references to the CSS in the rest of the site.
22 saffron // Jan 14, 2008 at 1:56 am
Hi kdmurry,
thank you for your help. Do you have any pointers for how I would change the code, what code I would need to change….where to start….???!
23 saffron // Jan 14, 2008 at 2:12 am
I have tried renaming the plugin slightly & uploading a second copy - but this did not work
24 Roy Petter // Jan 19, 2008 at 6:20 am
Thanks Keith for developing this plugin, it is just what I wanted for my blog. I had some problems with the previous version (I did not have the physical path) but I download v1.2.1 5 minutes ago, and click, click, click and now it is running. Thanks again and happy blogging
25 Roy Petter // Jan 19, 2008 at 6:25 am
Here is something for a wish-list, if you have one, I see several people are after something alike:
To enable RIS to pool from diferent libraries for diferent locations on the website (tipically, topbanner and sidebar banners).
26 Keith Murray // Jan 19, 2008 at 10:30 am
@Roy: I’m glad you like the plugin.

The request for RIS to handle multiple locations isn’t a new one, and it is something I’ve been thinking about. Truth is it would pretty much require a ground-up rewrite and that’s why it hasn’t been done yet.
But it is on the wish list… yes I do keep a list.
27 Random Image Selector_Wordpress plugin // Jan 22, 2008 at 8:57 pm
[...] Plugin Homepage [...]
28 Sebastian // Jan 26, 2008 at 9:06 pm
Keith, excellent plugin. I’ve been looking for something like this for a long time. I got it working as a sidebar block on Hemingway theme, which is the theme I use on my site.
I was wondering: is there any possibility of making something like a slideshow of images? The plugin changes the image everytime the page is refreshed or reloaded (ctrl+f5 on most browsers, tested on Firefox 2). I was wondering if theres a possibilite of changing the image automatically say, every 5 seconds, or ten seconds. Probably it would require some JS libraries, like Prototype, MooFX… or any other around. Just to make a cool transition effect.
But, is this possible at all without having to rewrite everything ground up? Unfortunately, my programming skills are not up to the task I believe…
Cheers from Buenos Aires!
Sebastián.
29 matteo // Jan 27, 2008 at 7:37 am
great plugin! thanks a lot! you gave me a great help to make my brand new blog charmish

i’ve just edited the img name portion of the php code to insert a fixed copyright statement
30 Sebastian // Jan 27, 2008 at 5:07 pm
I’ve managed to make a slideshow as a block on my Hemingway sidebar. I’d like to make it public, it may help someone, but I don’t have any idea of how to make a WP plugin out of it… I made it out of a simple CSS and JS layout I found here:
http://iamacamera.org/sandbox/photoshuffler/
I just made minor adjustments in order to adapt it for a hemingway block.
Perhaps this could be of some help to see if you could include as an option a slide.
Cheers!
Sebastián
31 Keith Murray // Jan 29, 2008 at 3:29 pm
Nice job, Sebastián! Any objections if I were to make a plugin out of this one?
32 Delete Dmoz // Jan 29, 2008 at 6:43 pm
Is there a demo?
Want to see how it crops before installing.
33 Sebastian // Jan 29, 2008 at 7:18 pm
Of course not! I’d be honoured! In fact I posted this because I don’t know how to make a plugin! I’m kinda “learning by doing”, without the learning part LOL!
I think soemething that could be done is provide an interface on the WP admin section to make the necessary modifications to the JS file. Of course, I made everything by hand, and I have no idea how to make a plugin out of it.
By mixing that, and adding the resizing part on your plugin, could make a nice thing I believe.
It will be my pleasure if you can make out of it something useful for other people.
Cheers!
Sebastián
34 Sebastian // Jan 29, 2008 at 7:26 pm
By the way… I didn’t do anything… I just implemented the code in Hemingway, but all the hard work goes to Carl Camera (www.iamacamera.org), his code does everything.
Cheers again! (I have to change the “cheers”, it’s becoming too repetitive hehe)
Sebastián.
35 Keith Murray // Jan 30, 2008 at 12:03 am
@Delete Dmoz: The plugin doesn’t crop or alter the original image at all. It will attempt to scale it if the scaling options are turned on, otherwise it will just place the image without modifying it.
The only demo is at the top of the page.
The plugin runs my image headers for this site.
36 Aaron // Feb 14, 2008 at 4:39 pm
Great plugin. Worked perfectly the first time in Wordpress v2.3.3.
I modified it by giving it my own title and alt names, other than that, pefect right outta the box!
37 CID // Mar 1, 2008 at 5:50 am
Hi,
I’ve installed the plugin but, this time around, I can’t get it to work… I’ve checked the absolute path to the specific folder I’m using with a php $_SERVER['SCRIPT_FILENAME'] call from that directory and I’ve checked the URL to the folder by ‘opening’ an image inside from the address bar… The paths I’ve entered are both correct. I even temporarily fully opened the rights on the folder. I’ve also tried to call the function from different parts/pages. All, regretfully, to no avail…
I did get it to work before, for a different site. And I do still would like to use the plugin because I like its simplicity. But this time, using version 1.2.1, I’m hitting a proverbial wall so to say…
Thanks in advance for your reply! Would be great if you could have a look at it…
Here are the details:
Path to the WP installation that was found by the plugin: /home/vhosts/eyes-on-mywork.com/httpdocs/eom/
Added: wp-content/featured/images
URL: http://eyes-on-mywork.com/eom/wp-content/featured/images
Thanks!!!
CID
38 CID // Mar 1, 2008 at 5:54 am
PS.:
1) The problem seems to be getting an image filename… I suspect. For: the image tag is written to the page but the src is empty…
2) Could there be any other server/rights settings that are preventing the plugin from reading the contents of the folder…? (I personally can’t think of any…)
Hope it helps… Thanks again!
39 naires // Mar 11, 2008 at 2:24 pm
great plugin! it work well also as a background body images, just play with z-index in the style.css and in the Radom Options (point 3) choose “Force a height/with” with the value 100% in the fields Height and With!
thanks!
40 naires // Mar 11, 2008 at 2:37 pm
in future releases it would be very nice features if you integrate the option to create more than one folder and then assign each folder to a category… for example: if i open category 1 the set of random images would be different from category 2 and so and so…
41 drumbo // Mar 14, 2008 at 5:08 am
Hi, great plugin.
Just to let you know that as is, the plugin will not validate against the XHTML validator. The reason being : the ALT tag is missing from the IMG selector. Easy to change, but might make a worthwhile addition.
Thanks again
42 Aaron // Mar 15, 2008 at 4:20 pm
Is there a way to set it so it excludes a particular page? I have just one page on my site that I’d like to always have a certain header image on, and I don’t want this to affect it.
43 Keith Murray // Mar 15, 2008 at 5:16 pm
@Drumbo: Thanks for the feedback, I’ll make sure to add that in the next update to make it xhtml compliant.
@Aaron: y default, most people include it in the header, which means it will show up on every page. If you added it to another page or another part of the template then you could more easily exclude it from other pages.
44 cuzzy // Apr 5, 2008 at 6:47 am
I am really hoping someone can help me. I have never had such a hard time using a plugin.
I have followed what is said to do and nothing.
When I ask where does it go, please do say, oh just throw it in the header.php.
I am not into code but I have installed many things into my blog.
I have installed, activated and setup the folders where the photos are.
no I have this piece of code you list.
where does this “exactly have to go”
screen shots would be great as well.
my email is michaelbcusden@gmail.com
I have tried a few of the random image header plugins and I don’t understand why they are so hard to use.
People seem to be getting it to work and I am getting frustrated.
any help would be great.
45 Keith Murray // Apr 6, 2008 at 12:03 am
Hi cuzzy,
Without knowing some detail about the wordpress theme you’re using it’s difficult to be specific. The reason you’ve had more difficulty with these types of plugins is that unlike most plugins these have to take into account the many different ways that the theme developers may choose to display an image.
In looking at your code I’ve found the following image tag:
<img src=”http://chocolatedogblog.com/wp-content/themes/RockinNewspaper-3Col-1-0/images/photo1.jpg” alt=”The Chocolate Dog Blog” />
If you replace that tag in your header file with the sample code that I’ve included in the documentation this should handle the problem.
46 jack // May 13, 2008 at 3:02 am
I am having a issue with subdirectories….It seems that when there is a subdirectory in a gallery folder..it gives this error: Warning Division by Zero….can you plz fix this problem…its Fixable
47 Keith Murray // May 13, 2008 at 12:19 pm
@Jack: Can you explain how you’ve got this set up? Is it a gallery folder containing both images and subfolders? or…?
48 Paul // May 16, 2008 at 1:47 am
I’m putting a site together at the moment, and was thinking about using this plugin.
When testing it, I found that you still have an alert box set to pop javascript info if ‘Height’ is selected as the scaling attribute. I’m aassuming that wasn’t intential, and figured you’d want to know.
49 Paul // May 17, 2008 at 2:58 pm
I had situation where I had a small amount of space to put the random image, that was constrained by both width and height, but I didn’t want to just force the dimensions and have the images look off.
I ended up creating a new scaling option, to scale by either width or height, depending on the circumstances (ie. if scaling by height would result in a width greater than that declared, scale by width instead).
It’s not complicated, but I figure it’s a useful feature. Email me if you want and I’ll send it over.
50 Keith Murray // May 17, 2008 at 7:15 pm
@Paul: Thanks for the heads up. I’ll shoot you a note and get that feature worked into the next version.
51 Markus // May 21, 2008 at 4:31 pm
Thanks very much for a great plugin. Keep up the good work!
52 Site Development » How does this website Run // May 21, 2008 at 5:55 pm
[...] Random Image Selector - Randomly Selects a Image from your Image folder, scales it using GD and then you customize its output. I could have used Awsom PIxGallery’s Widget but this one was a better choice for the front page. I also needed a smaller size picture then the one Awsom is producing in other galleries. [...]
53 John // Jun 13, 2008 at 8:25 am
Thank you
54 50+ Wordpress随机插件 | 帕兰映像 // Jul 1, 2008 at 3:38 am
[...] Random Image Selector: 从一个指定的文件夹里面随机显示其中的图片. [...]
55 pulsers // Jul 1, 2008 at 11:22 am
Hi, I just installed this plugin and it is working great. It’s just what I was looking for.
I was wondering, however, if there is a way to upload the images to the random image folder via WordPress? The person I am making the site may not be able to upload to the designated folder using a FTP program.
Thanks!
56 Phil // Jul 2, 2008 at 10:55 am
Hello,
Like Carla I also believe that I have installed and configured the plugin properly and placed the necessary code in my sidebar but nothing appears?!!?
What could I be missing?
In options the path that is being auto generated is:
/home3/pjewett/mactutorial-www/wordpress/
and I’ve added “wp-content/uploads/”
and the URL path is:
http://mactutorial.com/wordpress/wp-content/uploads/
57 Keith Murray // Jul 5, 2008 at 2:34 am
@Phil: This is a result of the images being stored in subfolders. Currently the plugin doesn’t support nested subfolders. This is a feature planned for a later release.
58 五毒 » Blog Archive » Wordpress随机插件 // Jul 10, 2008 at 6:36 pm
[...] 随机图片插件Random Image Selector: 从一个指定的文件夹里面随机显示其中的图片. Random Image widget: [...]
59 jose // Jul 13, 2008 at 1:27 am
Thanks for the work you made.
i would suggest one thing:
you create a line like this:
echo ”;
}
i wish if u still continue to work on future releases you ad the ability to click on the picture and open a bigger window with a larger picture.
i use your plug to display a random thumbnail, i just wish i click on it and display the full picture.
eg: thumbnails should be ex dir : xxx/tmb/ and full xxx/full/ and just random on the tmb dir but display the same name picture on full/ dir
anyway thanks for your work
60 xavi // Jul 29, 2008 at 4:42 am
I try to use this interesting plugin but no way. I introduce the pathname of the folder with the images but it is never found. Is there any problem with Mac OS (I am using Mac OS X 10.4.11. )?. Thanks
61 Jason // Aug 7, 2008 at 3:26 pm
hey everyone
keith, awesome plugin… works beautifully. i, like a few others, was really interested in getting the images to link. i didn’t hook up any database functionality but i did get the thumbnails to link to the full size image by:
editing randomImage.php
replace line 224 which looks like this:
echo ”;
with something like this:
echo ““;
hope that helps someone out there, and thanks again
62 Jason // Aug 7, 2008 at 3:27 pm
apologies… code above should’ve came out better, perhaps this will work:
replace linke 224 which looks like this:
echo ”;
with this:
echo ““;
63 Goofy // Aug 14, 2008 at 9:10 am
Having a problem. I can’t get the admin options to display in the admin template after I’ve installed the plugin. Thus I can’t set my directories or options for the plugin.
I’m using WP 2.51 on a server and on a localhost install. Neither works.
I’ve used this plugin before on other sites and and never had this problem.
64 Keith Murray // Aug 14, 2008 at 2:38 pm
@Goofy Best guess is that another plugin may be interfering with it. Try turning off other plugins until they’re all disabled, or until it works.
65 tony // Aug 20, 2008 at 6:20 am
Keith,
Great plugin!…….is it possible to have this plugin pull more than 1 random image?……i would like to show 5 random images on my homepage….i know it’s probably a tweak of the coding somewhere…..any help?
thanks
tony
66 Keith Murray // Aug 20, 2008 at 3:34 pm
@tony thanks for the feedback. That’s certainly something I can look at for a future version.
Time’s been tight lately and I haven’t had much time to do plugin development, but I’ll see what I can do…
67 ein blog eben, keiner weiss wieso » Plugin Roundup (1) // Aug 27, 2008 at 8:05 am
[...] Random Image Selector [...]
68 updates – adrianoafonso.net // Aug 29, 2008 at 4:20 pm
[...] a precisar de um já com widgets. Depois, acrescentei mais alguns plugins que me davam jeito, o Random Image Selector para finalmente por ali ao cantinho as imagens da minha galeria, ainda não faz o que quero mas já [...]
69 WordPress天下 » Blog Archive » 50个Wordpress随机插件 // Sep 1, 2008 at 6:16 am
[...] Random Image Selector: 从一个指定的文件夹里面随机显示其中的图片. [...]
70 CID // Sep 2, 2008 at 7:25 am
Hi Keith,
I posted a question a couple of months ago (posted march 1st). I stopped development of the site I mentioned because of other work but am now getting back to it. The issues I mentioned still persist (obviously it doesn’t solve itself…) .
You (probably) overlooked my posts last time…
Could you have a look at them? Thanx in advance!
Some additional details:
- I am now using WP 2.6.1
- Does the directory have to be in the ‘wp-content’ folder?
Grtz!
CID
71 mowog // Sep 2, 2008 at 12:11 pm
Hey K,
I have a question for you about this WordPress random image plugin. I am using it generate a random header image as a background because I have text that needs to overlap it. I modified the last couple lines of the plugin code to generate “url(” instead of an image tag so I can use it inside a CSS rule in the header.php template file of my theme. It seems to work fine about 50% of the time. The other 50% of the time no image will load. When I look at the page source of a failed load, I noticed that the image directory has a “._” in front of the image file that isn’t supposed to be there (i.e. it reads “…/._ucheader01.jpg” instead of …/ucheader01.jpg”. This is what causes the image to not load properly. You can visit my test site to see what I mean: http://upstatecruisers.net/test_blog
Do you know why this is happening? It occurred before I edited the plugin code as well, and if it matters the folder that contains the images is in the theme folder.
Thanks for your help, I look forward to being able to use it!
72 Плагин "Random Image Selector" для вывода случайной картинки в шаблоне блога. // Sep 3, 2008 at 3:40 pm
[...] плагина: Keith Murray (http://kdmurray.net/) Страница плагина: http://kdmurray.net/2007/12/09/random-image-selector... Рассматриваемая версия: 1.2.5 от 02.08.2008 Совместимость с [...]
73 Stephanie // Sep 11, 2008 at 9:07 am
Help! I installed the plugin and activated it and I don’t have an “options” screen. The only other plugin I have is wordpress stats. What should I do?
74 Keith Murray // Sep 11, 2008 at 9:55 pm
@Stephanie: In newer versions of WordPress the menu you want is called “Settings”. There should be a “Random Image” menu item under the settings menu that you can use to configure the plugin.
75 Kelly // Sep 14, 2008 at 6:58 am
This is exactly what I was looking for!! Thanks! One question… is it possible to have the random images wrap inside the paragraph? Thanks!
76 şarkı sözleri // Sep 17, 2008 at 12:15 am
I installed the plugin end worked. Thanks
77 50+ Wordpress随机插件 // Sep 24, 2008 at 8:30 pm
[...] Random Image Selector: 从一个指定的文件夹里面随机显示其中的图片. [...]
78 Crossings Community Church » The To Do List for Our Web Site Ministry Team // Oct 5, 2008 at 4:44 pm
[...] asked, David will install the Random Image Selector so that photos will rotate each time a web page is refreshed. This is what EVAC uses for their [...]
Leave a Comment