Display a random background image each time the page is loaded
thenickdude
Registered Users Posts: 1,302 Major grins
Hey everyone,
This customisation allows you to load a different background image on your site each time the page is loaded.
You can find the details here:
http://www.sherlockphotography.org/Customisations/Random-background-image
Here's an example page which uses that code:
http://www.sherlockphotography.org/Customisations/Random-background-image/Example
This customisation allows you to load a different background image on your site each time the page is loaded.
You can find the details here:
http://www.sherlockphotography.org/Customisations/Random-background-image
Here's an example page which uses that code:
http://www.sherlockphotography.org/Customisations/Random-background-image/Example
https://www.sherlockphotography.org/
Please check out my gallery of customisations for the New SmugMug, more to come!
Please check out my gallery of customisations for the New SmugMug, more to come!
0
Comments
I don't know how ugly the code gets, but any chance you could share a sample that could be modified manually?
Dave
Good one Nicholas ... Love to implement this . Do we have the tweak inside same CSS to provide the auto-random rather force refresh each time ?
Ah, gotcha. I've updated the generator now so you can just enter the number of photos you want to switch between instead of entering a gallery URL. It'll generate some empty code for you to fill in. e.g. for randomly switching between 5 images, the HTML is:
And the CSS is:
The code looks a lot less ugly if you turn off wordwrapping in the editor... . Just fill in those urls where it says "image1" etc.
You shouldn't need to force refresh, it should change on every simple page load.
Please check out my gallery of customisations for the New SmugMug, more to come!
Sorry Lamah , by force refresh I mean auto load of the page . I would like this to be as like random slideshow image display but not as slideshow .
Any chance you can modify this to pluck images from my popular photo list and use it on a thumbs list on my home page?
www.brandolinoimaging.com
I have a short list on the left right now but it's static and gets old quick.
You can add this custom CSS as a block on your page instead of adding the CSS to your theme as the instructions say:
Now add 5 HTML content blocks to the page, each using the HTML and CSS that the generator creates for you. You can use the Dimensions settings for the blocks to set their width. The result looks something like this:
http://www.sherlockphotography.org/Test/n-C9s7M
There are some caveats here:
- The thumbs aren't clickable
- The generator always chooses the largest available image, which will be way too large. You might want to find-and-replace X3,X2,XL, etc with S in the URLs for the images.
- The SmugMug page editor doesn't allow you to put multiple HTML content blocks into one column, and be able to add a block to the right of that entire column (it will force the right content block and the first thumbnail to be on the same row, with the same height).
These issues could be solved by me adding substantial features to the generator, but I'm working on other things at the moment.
A service which provided an RSS feed for the Feeds block would be much simpler, and much faster to load.
Please check out my gallery of customisations for the New SmugMug, more to come!
Thanks for the reply. Nice outcome on the page... How do you achieve the centering of those images? I have found no other way than to add a blank/ empty div content box to the left to push the images over until centered.
The images are probably centred because my page is set to fixed-width.
Please check out my gallery of customisations for the New SmugMug, more to come!
oh, its a page with a popular image block... gotcha... I'll need to use the real popular image gallery
either
Please check out my gallery of customisations for the New SmugMug, more to come!
I can see how to simply stack 5 or 6 divs in the html, but the current code generated the same pic for each div. Is there an "easy" way to get each div within the same html box to generate a different pic?
I figure if I changed the div name in the css code it would do it, but I wanted to ask 1st as the gallery has 400+ pics
That's a lot o code!!!
My hang up for going live is the lack of client login so I guess i have a catch 22 at the moment with my problem unless someone else has had this problem and can suggest a solution without actually being able to see my page since it's still in sandbox mode lol.
__________________________________
http://www.MakeItABradford.com
Have you seen the client login system customisation on my site?
Please check out my gallery of customisations for the New SmugMug, more to come!
But yes I put the gallery generated stuff and that HTML in the theme's CSS. I think i put the other stuff in a css box on homepage.
Please advise.
__________________________________
http://www.MakeItABradford.com
Please check out my gallery of customisations for the New SmugMug, more to come!
__________________________________
http://www.MakeItABradford.com
__________________________________
http://www.MakeItABradford.com
I'm not sure if you've already fixed this bug or not but I thought I'd mention it.
I implemented the random background (although since removed it) to have it load a different background every time any one of my pages is loaded. I added a HTML block to the "Entire Site" with the HTML/CSS. It's been a couple weeks since I did this so I can't remember the instructions (and I can't get to your site while at work) ... I think I also had to add a smidge of CSS to my theme's CSS (advanced settings)?
When I visited a page that extended beyond the height of the screen and required scrolling, it would cause a number of issues. In collage layouts, some of the images got moved all over. In SmugMug layout, if the caption was long, you would not be able to click on the text (to highlight it) or click on any links. You had to scroll back up to the top of the page to be able to select text and click on links. I had to remove the code because of it.
If you'd like I can throw together a sample test gallery and see if the bug still exists.
Former SmugMug Product Team
aaron AT aaronmphotography DOT com
Website: http://www.aaronmphotography.com
My SmugMug CSS Customizations website: http://www.aaronmphotography.com/Customizations
Look how clever this is. Just to make sure I actually get it, what you're doing here is hooking into the class .sm-page-widget-body which has an id of sm-page-widget-<random alphanumeric string>. Then via use of the CSS3 $ selector you're saying, hey, if the first character of the string in the id is a through l, display image1, if it is m through y, display image2, if it is z through K, image 3, and so on for all 62 available characters. You could, therefore, have 62 unique images using this method. I suppose if you used the first and second characters from aa to 00 you could have 62^2 = 3844 unique images (though the css would get a bit unruly!).
Am I understanding that properly? If I've got it wrong, then I may be misunderstanding how the [id$=*] selector works. Is it the case that this selector is looking only at the first character of the random string? (Also, I'm only assuming that this 8 character string actually is randomly generated by SM upon each page load. Is that the case?)
http://photos.mikelanestudios.com/
SM does indeed generate that ID randomly on every pageload. I think this is their way of ending up with a unique ID to later refer to elements they've added to the page, without having to have all their code co-ordinate on one central counter which would be required to generate IDs sequentially.
Please check out my gallery of customisations for the New SmugMug, more to come!
Brilliant. I need to investigate that selector more, it seems. Would id$=ab look at the last two characters of that unique id string and display the image if it ended in "ab"?
EDIT: From W3C: "The [attribute$=value] selector matches every element whose attribute value ends with a specified value." Reading, it's FUNdamental.
http://photos.mikelanestudios.com/
Let me add to chorus. I've had your background randomizer up on my site since late October. I remember looking at the code when I got it and realizing, "I'm looking at a truly amazing example of lateral thinking." I didn't write to thank you at the time. I do now.
Jim Ringland
jtringl.smugmug.com
Please check out my gallery of customisations for the New SmugMug, more to come!
Jim Ringland
jtringl.smugmug.com