Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Placing a random image

From: Joomla! 1.5: Creating and Editing Custom Templates

Video: Placing a random image

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.

Placing a random image

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.

Show transcript

This video is part of

Image for Joomla! 1.5: Creating and Editing Custom Templates
Joomla! 1.5: Creating and Editing Custom Templates

25 video lessons · 23028 viewers

Jen Kramer
Author

 

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Joomla! 1.5: Creating and Editing Custom Templates.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.