13 lines
577 B
JavaScript
13 lines
577 B
JavaScript
// Test getImageUrl function
|
|
const BASE_API_URL = 'http://127.0.0.1:8000'\;
|
|
const getImageUrl = (imagePath) => {
|
|
if (!imagePath) return '/assets/images/work/placeholder.jpg'
|
|
if (imagePath.startsWith('http')) return imagePath
|
|
return `${BASE_API_URL}${imagePath}`
|
|
}
|
|
// Test cases
|
|
console.log('Test 1 - API path:', getImageUrl('/media/uploads/portfolio/a2afc48f6532427cac863619563e3800.avif'));
|
|
console.log('Test 2 - Full URL:', getImageUrl('http://example.com/image.jpg'));
|
|
console.log('Test 3 - Null:', getImageUrl(null));
|
|
console.log('Test 4 - Empty:', getImageUrl(''));
|