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:
mstfyldz
2026-05-04 21:07:49 +03:00
parent 262f31a704
commit dbf13ee382
134 changed files with 240 additions and 666 deletions

53
upload-remaining.js Normal file
View File

@@ -0,0 +1,53 @@
require('dotenv').config();
const cloudinary = require('cloudinary').v2;
const fs = require('fs');
const path = require('path');
cloudinary.config({
cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
api_key: process.env.CLOUDINARY_API_KEY,
api_secret: process.env.CLOUDINARY_API_SECRET,
});
const FOLDER = 'muglasurucukursu';
const LOCAL_DIR = path.join(__dirname, 'images');
async function uploadAll() {
const files = fs.readdirSync(LOCAL_DIR).filter(f => {
const stat = fs.statSync(path.join(LOCAL_DIR, f));
return stat.isFile() && /\.(jpg|jpeg|png|svg|webp)$/i.test(f);
});
console.log(`📸 ${files.length} resim bulundu. Yükleme başlıyor...\n`);
const results = {};
for (const file of files) {
const filePath = path.join(LOCAL_DIR, file);
const publicId = `${FOLDER}/${path.parse(file).name}`;
try {
const result = await cloudinary.uploader.upload(filePath, {
public_id: publicId,
overwrite: true,
resource_type: 'image',
});
results[file] = result.secure_url;
const sizeKB = (fs.statSync(filePath).size / 1024).toFixed(0);
console.log(`${file} (${sizeKB}KB) → ${result.secure_url}`);
} catch (err) {
console.error(`${file} yüklenemedi:`, err.message);
}
}
// URL mapping'i kaydet
fs.writeFileSync(
path.join(__dirname, 'cloudinary-urls-images.json'),
JSON.stringify(results, null, 2)
);
console.log(`\n🎉 ${Object.keys(results).length}/${files.length} resim yüklendi.`);
}
uploadAll();