The original Random Image displayed rotating banners and photos from a directory. Today, JavaScript carousels and image APIs offer dynamic, animated solutions with better performance.
Image Display
Modern mobile touch slider with hardware accelerated transitions. Framework agnostic with support for React, Vue, and Angular. Includes lazy loading, virtual slides, and parallax effects.
Lightweight, flexible slider with no dependencies. Written in TypeScript with full type support. Features multiple slides, thumbnails, and video integration.
Dependency-free ES6 slider with modular architecture. Small footprint with keyboard navigation and responsive breakpoints. Supports autoplay and multiple transition effects.
Touch-enabled, responsive carousel with physics-based animation. Includes accessible controls, auto-play, and lazy loading. Works great for gallery and product images.
Beautiful, free images from professional photographers. High-quality photos with random endpoint, search by topic, and curated collections. Perfect for hero images and backgrounds.
https://source.unsplash.com/random/800x600
https://source.unsplash.com/random/800x600?nature
Easy placeholder images for development and testing. Simple URL-based API with no authentication required. Specify dimensions, blur, and grayscale effects directly in the URL.
<img src="https://picsum.photos/400/300?random=1">
<img src="https://picsum.photos/400/300?blur=2">
Free stock photos and videos API. Extensive library with search, curated collections, and trending content. Includes attribution data and multiple image sizes.
Placeholder images featuring adorable kittens. Simple URL-based service perfect for development and testing. Brings joy to your mockups.
<img src="https://placekitten.com/400/300">
const images = [
'/images/banner1.jpg',
'/images/banner2.jpg',
'/images/banner3.jpg',
'/images/banner4.jpg'
];
const randomIndex = Math.floor(Math.random() * images.length);
document.getElementById('banner').src = images[randomIndex];
// Or with CSS background:
document.body.style.backgroundImage = `url('${images[randomIndex]}')`;
// Preload images for smooth experience:
images.forEach(src => {
const img = new Image();
img.src = src;
});
<?php
$imageDir = 'images/banners/';
$images = glob($imageDir . '*.{jpg,jpeg,png,gif}', GLOB_BRACE);
$randomImage = $images[array_rand($images)];
?>
<img src="<?php echo htmlspecialchars($randomImage); ?>" alt="Random banner">
const images = [
{ src: '/images/featured.jpg', weight: 5 },
{ src: '/images/banner1.jpg', weight: 1 },
{ src: '/images/banner2.jpg', weight: 1 }
];
// Featured image gets 5/7 = 71% chance
const totalWeight = images.reduce((sum, img) => sum + img.weight, 0);
let random = Math.random() * totalWeight;
for (const img of images) {
if (random < img.weight) {
document.getElementById('banner').src = img.src;
break;
}
random -= img.weight;
}
Rotate advertising banners with weighted selection for premium advertisers.
Show different hero images on each page load to keep design fresh.
Display random featured products or deals on homepage.
Show random images from photography portfolio or travel gallery.
| Feature | Random Image CGI | Modern Solutions |
|---|---|---|
| Transitions | None | CSS/JS animations |
| Lazy loading | No | Built-in |
| Touch/Swipe | No | Yes |
| Responsive | No | Yes |
| Thumbnails | No | Yes |
| Autoplay | Page refresh | Continuous |
| Server load | Each request | Client-side |
| Caching | Limited | Browser cache |
| Image effects | No | Zoom, blur, parallax |
Full-featured: Swiper
Lightweight: Splide or Glide.js
Simple rotation: Vanilla JavaScript
API images: Unsplash
Placeholders: Lorem Picsum
npm install swiper
npm install @splidejs/splide
npm install @glidejs/glide
npm install flickity