Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
One of the fun effects that comes built into Joomla! is the ability to add a random image to your webpage and it can add a lot of interest to your website. I am looking at the Ordering page of our site right now and if I hit my Refresh button, most of the time when I refresh the page, a different image will come up. So I would like to go through how you go about setting this up. If you go over to the back-end of Joomla! and make sure that you are logged in, let's take a look at the module itself. So under Extensions in the Module Manager, you can find Random Image right in our list. It's called Random Image and you are probably familiar with some of these settings from other modules that you have worked with. Just like every other module, there is a title, which you can show or not show on the website, that it's Enabled and then it's in Left Position. It's available for all the users and then it's assigned to certain pages of the website here in our list.
Specific to the Random Image module though is the right hand side of the page. These settings point to a specific location in the images/stories directory where all of the images live. The way this is set up right now is to say to find all PNG files that live within the images/stories folder and display them randomly on the website. Ahead of this, I had already taken all of these images and cropped them such that they are all a 162 pixels wide. Keeping all of your images a constant size gives that site a little bit more of a professional polish. If they are slightly different sizes, they may interfere with text surrounding the images and it may actually even expand or reduce the size of the website overall.
Using a consistent size gives it a final polish. I am going to close this window. I am going to show you the Media Manager, which is under Site > Media Manager. All of the images that are used on your website should reside within the stories folder in Joomla!. Inside of the stories folder, you can make other folders where images will also live. But in this particular site, I have chosen not to do that. All of the images that you see here are used in the Random Image module, except for these two images; newsbar and newsbox. These are the two pictures that are used in the Latest News module on the Home page. They end in .jpg instead of .png. That's why they are not picked up by the Random Image module.
Let's take a look at how we can style this a little bit better on the front of the website. Most of the graphic designers would say that this left edge of this image should probably be lined up with the left edge of the B in Bliss up top. It will just give it a little bit more polish and a little bit more style. So we are going to go to CSS, Edit CSS again and the Default tab and I think we can probably just do this with one style. If I view the source of the webpage and I take a look at the left side, here is our div with id of left, you will see that we have a div with a class of moduletable and another div inside of it that's outlining the image inside of that div in the center. Our image has a width of a 162 pixels.
What we are going to do is we are going to take this div of moduletable and make it a 162 pixels. That will automatically affect this other div that has no class or id assigned to it. It will also shrink down to 162 pixels and everything will wrap nice and tight around this image. So back over to our code and I am going to add div.moduletable. First I am going to make the width 162 pixels. That pushes it all the way to the left hand side of the page.
I need a little bit more space so that I can line it up under the B. I have already worked out with that padding should be in advance. I am putting 3 ems on the top of this so that there maybe a little bit space between the random image and any other modules that appear on this page. Plus it gives us a little bit of space between the top logo and the random image itself. And 40 pixels over on the left, which will push this over just nicely. Then once again, Ctrl+A or Command+A, Ctrl+C or Command+C, back to the back-end of Joomla! to Extensions > Template Manager.
In the Template Manager, select our inside template, Edit, Edit CSS, choose default CSS and Edit, once again Ctrl+ A or Command+A, Ctrl+V or Command+V to paste in our changes and save and now when we go to the Ordering page and refresh, a different image may load but you can see that the alignment is much better. The Random Image module loads different images in the same location on the same webpage. This is something that you can't do with static HTML and it's very easy to set up and use within Joomla!. It's a great feature for adding a lot of interest to your webpages.
Get unlimited access to all courses for just $25/month.Become a member
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.