| 12345678910111213141516171819202122232425262728 |
- /**
- * 이미지 URL 헬퍼 composable
- */
- export const useImage = () => {
- const config = useRuntimeConfig()
- /**
- * 이미지 상대 경로를 절대 URL로 변환
- * @param {string} path - 이미지 상대 경로 (예: "/uploads/images/abc.jpg")
- * @returns {string} - 전체 URL (예: "http://gojinaudi.mycafe24.com/uploads/images/abc.jpg")
- */
- const getImageUrl = (path) => {
- if (!path) return ''
- // 이미 전체 URL인 경우 그대로 반환
- if (path.startsWith('http://') || path.startsWith('https://')) {
- return path
- }
- // 상대 경로인 경우 imageBase 붙이기
- const imageBase = config.public.imageBase
- return `${imageBase}${path}`
- }
- return {
- getImageUrl
- }
- }
|