feat: migrate all images to Cloudinary CDN
- Uploaded 42 active images to Cloudinary with auto optimization - Removed 72 unused theme placeholder images - Deleted local images/ directory entirely - All images now served via Cloudinary CDN with f_auto,q_auto
This commit is contained in:
42
replace-remaining-urls.js
Normal file
42
replace-remaining-urls.js
Normal file
@@ -0,0 +1,42 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const urls = JSON.parse(fs.readFileSync(path.join(__dirname, 'cloudinary-urls-images.json'), 'utf-8'));
|
||||
const FILES = ['index.html', 'about.html', 'contact.html', 'courses.html', 'services.html', 'team.html', 'css/custom.css'];
|
||||
const CLOUD_BASE = 'https://res.cloudinary.com/du7xohbct/image/upload/f_auto,q_auto';
|
||||
|
||||
let totalReplacements = 0;
|
||||
|
||||
for (const file of FILES) {
|
||||
const filePath = path.join(__dirname, file);
|
||||
if (!fs.existsSync(filePath)) continue;
|
||||
|
||||
let content = fs.readFileSync(filePath, 'utf-8');
|
||||
let fileCount = 0;
|
||||
|
||||
for (const [filename, cloudUrl] of Object.entries(urls)) {
|
||||
// Add f_auto,q_auto optimization to URL
|
||||
const optimizedUrl = cloudUrl.replace('/image/upload/', '/image/upload/f_auto,q_auto/');
|
||||
const localPath = `images/${filename}`;
|
||||
|
||||
// Escape for regex
|
||||
const escaped = localPath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
const regex = new RegExp(escaped, 'g');
|
||||
const matches = content.match(regex);
|
||||
|
||||
if (matches) {
|
||||
fileCount += matches.length;
|
||||
content = content.replace(regex, optimizedUrl);
|
||||
}
|
||||
}
|
||||
|
||||
if (fileCount > 0) {
|
||||
fs.writeFileSync(filePath, content);
|
||||
console.log(`✅ ${file}: ${fileCount} yol güncellendi`);
|
||||
totalReplacements += fileCount;
|
||||
} else {
|
||||
console.log(`⏭️ ${file}: değişiklik yok`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`\n🎉 Toplam ${totalReplacements} resim yolu güncellendi!`);
|
||||
Reference in New Issue
Block a user