Add imagekit fallback on no imagekit ID
This commit is contained in:
		@@ -31,7 +31,7 @@ var Config *config
 | 
			
		||||
func Load() *config {
 | 
			
		||||
	err := godotenv.Load()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		slog.Error("Error loading .env file - Using environment variables instead")
 | 
			
		||||
		slog.Warn("Error loading .env file - Using environment variables instead")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Get mastodon instance
 | 
			
		||||
@@ -86,7 +86,7 @@ func Load() *config {
 | 
			
		||||
 | 
			
		||||
	imageKitId := os.Getenv("CAOM_IMAGEKIT_ID")
 | 
			
		||||
	if imageKitId == "" {
 | 
			
		||||
		slog.Info("No imagekit id provided, not using imagekit")
 | 
			
		||||
		slog.Info("No imagekit id provided, not using imagekit.io")
 | 
			
		||||
	}
 | 
			
		||||
	// Inititlize AppContext
 | 
			
		||||
	var appContext = &config{
 | 
			
		||||
 
 | 
			
		||||
@@ -12,9 +12,15 @@ func InitImgKitHelper() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func GetPreviewUrl(url string) string {
 | 
			
		||||
	if config.Config.ImageKitId == "" {
 | 
			
		||||
		return url
 | 
			
		||||
	}
 | 
			
		||||
	return "https://ik.imagekit.io/" + config.Config.ImageKitId + "/tr:w-500,h-500,c-at_max,f-webp,q-60/" + url
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func GetRemoteUrl(url string) string {
 | 
			
		||||
	if config.Config.ImageKitId == "" {
 | 
			
		||||
		return url
 | 
			
		||||
	}
 | 
			
		||||
	return "https://ik.imagekit.io/" + config.Config.ImageKitId + "/tr:q-70,dpr-auto,f-webp/" + url
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user