WordPress.org

Forums

Pre-loading images? (3 posts)

  1. mollysummer
    Member
    Posted 9 years ago #

    I'm trying to use a rollover image on the following blog : http://www.thecowgoddess.com/wordpress
    and when I test it works well. When my friend tests, she says it 'breaks up and looks funny' when she clicks the header links.
    I assume this is a problem with the preloading? is it not preloading? Is there some simple WP way to pre-load images?
    I did several searches but every search I did had no results.

  2. Michael Bishop

    Posted 9 years ago #

    What browser are you using, and is she using. It looks fine in FF, but IE is another beast....

  3. It looks a little strange on IE in general, but the 5 image rollovers at the top of the page appear to work okay for me. But on both FF and IE, it takes a second for the first rollover to work. Pre-loading will eliminate that minor delay.

    The best way to preload images is a little CSS trick.

    Add this to your style.css somewhere:
    .hiddenPic {display:none;}

    Then you can preload images pretty much anywhere you like on the page. Preferably near where they will actually be used. You preload them like so:
    <img src="image_to_preload.jpg" height="100" width="100" class="hiddenPic">

    Obviously, you want to change the width and height and such. You may also need to add an alt and a title to make the page pass an XHTML validation.

    Anyway, the hiddenpic basically just makes the image not displayed. But the browser still loads and caches it. Works in any CSS capable browser.

    Downside of this trick is that non-CSS browsers will show the images. But then, your page already looks like total hell without the CSS (as do most modern pages), so it's probably not worth worrying about in that case.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags