Description
Replace those gif images with jpgs with higher quality and smaller filesizes.
Use this script to do it. Works with any image format too (.jpg/.gif/.png).
Demo
JavaScript
- $(".jpgs img").ready(function() {
- $(".jpgs img").hide();
- });
-
- $(".jpgs").ready(function() {
- $(".jpgs").each(function(i) {
- var numImages = $(this).children("img").length;
- $(this).children("img").each(function(j) {
- $(this).wait(j*4000);
- fadeImage($(this),((numImages-1)*4000)-3000);
- });
- });
- });
-
- function fadeImage(obj, total) {
- obj.fadeIn(1000, function() {
- obj.wait(3000);
- obj.fadeOut(1000, function() {
- obj.wait(total);
- fadeImage(obj,total);
- });
- });
- }
CSS
- #jpg_example1,
- #jpg_example2,
- #jpg_example3,
- #gif_example {
- margin: 10px;
- }
-
- #jpg_example1,
- #jpg_example2 {
- width: 150px;
- height: 150px;
- }
-
- #jpg_example3,
- #gif_example1 {
- width: 400px;
- height: 300px;
- }
-
- /*Jpg Styling*/
- .jpgs img {
- position: absolute;
- }
XHTML
- <div id="jpg_example1" class="jpgs">
- <img src="jpg1.jpg" alt="jpg 1" title="jpg 1" />
- <img src="jpg2.jpg" alt="jpg 2" title="jpg 2" />
- <img src="jpg3.jpg" alt="jpg 3" title="jpg 3" />
- </div>
-
- <div id="jpg_example2" class="jpgs">
- <img src="jpg1.jpg" alt="jpg 1" title="jpg 1" />
- <img src="jpg2.jpg" alt="jpg 2" title="jpg 2" />
- <img src="jpg3.jpg" alt="jpg 3" title="jpg 3" />
- <img src="jpg4.jpg" alt="jpg 4" title="jpg 4" />
- <img src="jpg5.jpg" alt="jpg 5" title="jpg 5" />
- </div>
-
- <div id="jpg_example3" class="jpgs">
- <img src="jpgimage1.jpg" alt="jpg image 1" title="jpg image 1" />
- <img src="jpgimage2.jpg" alt="jpg image 2" title="jpg image 2" />
- <img src="jpgimage3.jpg" alt="jpg image 3" title="jpg image 3" />
- <img src="jpgimage4.jpg" alt="jpg image 4" title="jpg image 4" />
- </div>
-
- <div id="gif_example">
- <img src="gif1.gif" alt="gif 1" title="gif 1" />
- </div>
-