Spaces:
Sleeping
Sleeping
File size: 6,620 Bytes
e9e471e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Image Display Test - Shorter Names</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 1200px;
margin: 0 auto;
padding: 20px;
background-color: #f5f5f5;
}
.header {
text-align: center;
margin-bottom: 30px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 20px;
border-radius: 10px;
}
.image-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 20px;
margin-bottom: 30px;
}
.image-card {
background: white;
border-radius: 10px;
padding: 15px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
text-align: center;
}
.image-card img {
max-width: 100%;
height: auto;
border-radius: 8px;
margin-bottom: 10px;
}
.image-name {
font-weight: bold;
color: #333;
margin-bottom: 5px;
}
.image-description {
color: #666;
font-size: 14px;
}
.controls {
background: white;
padding: 20px;
border-radius: 10px;
margin-bottom: 20px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.btn {
background: #667eea;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
margin: 5px;
}
.btn:hover {
background: #5a6fd8;
}
</style>
</head>
<body>
<div class="header">
<h1>🖼️ Image Display Test</h1>
<p>Testing shorter image naming and display functionality</p>
</div>
<div class="controls">
<h3>Image Management</h3>
<button class="btn" onclick="loadImages()">Load Images</button>
<button class="btn" onclick="generateNewImage()">Generate New Image</button>
<button class="btn" onclick="clearImages()">Clear All</button>
</div>
<div id="imageContainer" class="image-grid">
<!-- Images will be loaded here -->
</div>
<script>
// Shorter image naming system
function generateShortName(topic, index = 0) {
const timestamp = Date.now().toString().slice(-6); // Last 6 digits of timestamp
const topicShort = topic.replace(/[^a-zA-Z0-9]/g, '').toLowerCase().slice(0, 8);
return `img_${topicShort}_${timestamp}_${index}`;
}
// Sample images with shorter names
const sampleImages = [
{
name: generateShortName('algebra', 0),
description: 'Algebra concepts visualization',
url: 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAwIiBoZWlnaHQ9IjMwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjZjBmOGZmIi8+CiAgPHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSJBcmlhbCIgZm9udC1zaXplPSIyNCIgZmlsbD0iIzMzMyIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZHk9Ii4zZW0iPkFsZ2VicmE8L3RleHQ+CiAgPHRleHQgeD0iNTAlIiB5PSI2MCUiIGZvbnQtZmFtaWx5PSJBcmlhbCIgZm9udC1zaXplPSIxNiIgZmlsbD0iIzY2NiIgdGV4dC1hbmNob3I9Im1pZGRsZSI+Q29uY2VwdHM8L3RleHQ+Cjwvc3ZnPg=='
},
{
name: generateShortName('geometry', 0),
description: 'Geometric shapes and formulas',
url: 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAwIiBoZWlnaHQ9IjMwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjZmZmMGYwIi8+CiAgPGNpcmNsZSBjeD0iMjAwIiBjeT0iMTUwIiByPSI1MCIgZmlsbD0iIzMzMyIgZmlsbC1vcGFjaXR5PSIwLjMiLz4KICA8cmVjdCB4PSIxNTAiIHk9IjIwMCIgd2lkdGg9IjEwMCIgaGVpZ2h0PSI1MCIgZmlsbD0iIzMzMyIgZmlsbC1vcGFjaXR5PSIwLjMiLz4KICA8dGV4dCB4PSIyMDAiIHk9IjE0MCIgZm9udC1mYW1pbHk9IkFyaWFsIiBmb250LXNpemU9IjI0IiBmaWxsPSIjMzMzIiB0ZXh0LWFuY2hvcj0ibWlkZGxlIj5HZW9tZXRyeTwvdGV4dD4KPC9zdmc+'
},
{
name: generateShortName('physics', 0),
description: 'Physics equations and diagrams',
url: 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAwIiBoZWlnaHQ9IjMwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjZjBmOGZmIi8+CiAgPGxpbmUgeDE9IjEwMCIgeTE9IjEwMCIgeDI9IjMwMCIgeTI9IjIwMCIgc3Ryb2tlPSIjMzMzIiBzdHJva2Utd2lkdGg9IjMiLz4KICA8Y2lyY2xlIGN4PSIxMDAiIGN5PSIxMDAiIHI9IjEwIiBmaWxsPSIjNjY2Ii8+CiAgPGNpcmNsZSBjeD0iMzAwIiBjeT0iMjAwIiByPSIxMCIgZmlsbD0iIzY2NiIvPgogIDx0ZXh0IHg9IjIwMCIgeT0iMjUwIiBmb250LWZhbWlseT0iQXJpYWwiIGZvbnQtc2l6ZT0iMjQiIGZpbGw9IiMzMzMiIHRleHQtYW5jaG9yPSJtaWRkbGUiPlBoeXNpY3M8L3RleHQ+Cjwvc3ZnPg=='
}
];
function loadImages() {
const container = document.getElementById('imageContainer');
container.innerHTML = '';
sampleImages.forEach((image, index) => {
const imageCard = document.createElement('div');
imageCard.className = 'image-card';
imageCard.innerHTML = `
<img src="${image.url}" alt="${image.description}" onerror="this.style.display='none'">
<div class="image-name">${image.name}</div>
<div class="image-description">${image.description}</div>
`;
container.appendChild(imageCard);
});
}
function generateNewImage() {
const topics = ['math', 'science', 'history', 'english', 'art'];
const randomTopic = topics[Math.floor(Math.random() * topics.length)];
const newImage = {
name: generateShortName(randomTopic, Math.floor(Math.random() * 100)),
description: `Generated image for ${randomTopic}`,
url: `https://via.placeholder.com/400x300/667eea/ffffff?text=${randomTopic.toUpperCase()}`
};
sampleImages.push(newImage);
loadImages();
}
function clearImages() {
document.getElementById('imageContainer').innerHTML = '';
}
// Load images on page load
window.onload = function() {
loadImages();
};
</script>
</body>
</html>
|