|
21 | 21 | <!-- Fix for subdirectory baseURL deployments like GitHub Pages --> |
22 | 22 | {{- $cleanImagePath := $imagePath -}} |
23 | 23 |
|
24 | | - <!-- Strip baseURL prefix if it exists in the imagePath --> |
25 | | - {{- $baseURLPath := strings.TrimSuffix "/" (strings.TrimPrefix ($.Site.BaseURL | urls.Parse).Path "/") -}} |
26 | | - {{- if and (ne $baseURLPath "") (hasPrefix $imagePath (printf "/%s/" $baseURLPath)) -}} |
27 | | - {{- $cleanImagePath = strings.TrimPrefix (printf "/%s/" $baseURLPath) $imagePath -}} |
| 24 | + <!-- Remove common problematic prefixes that cause resources.Match to fail --> |
| 25 | + {{- if hasPrefix $imagePath "/hinode-mod-image-lightbox-gallery/" -}} |
| 26 | + {{- $cleanImagePath = strings.TrimPrefix "/hinode-mod-image-lightbox-gallery/" $imagePath -}} |
28 | 27 | {{- else if hasPrefix $imagePath "/" -}} |
29 | 28 | {{- $cleanImagePath = strings.TrimPrefix "/" $imagePath -}} |
30 | 29 | {{- end -}} |
|
38 | 37 | {{- $images = resources.Match (printf "%s*" $cleanImagePath) -}} |
39 | 38 | {{- $images = where $images "MediaType.MainType" "image" -}} |
40 | 39 |
|
41 | | - <!-- If no images found, try alternative matching patterns --> |
| 40 | + <!-- Debug: Add warning if no images found to help troubleshoot --> |
42 | 41 | {{- if eq (len $images) 0 -}} |
43 | | - <!-- Try without leading slash --> |
44 | | - {{- $altPath := strings.TrimPrefix "/" $imagePath -}} |
45 | | - {{- if not (hasSuffix $altPath "/") -}} |
46 | | - {{- $altPath = printf "%s/" $altPath -}} |
47 | | - {{- end -}} |
| 42 | + {{- warnf "Gallery: No images found for path '%s' (cleaned from '%s'). Available resources pattern would be: '%s*'" $cleanImagePath $imagePath $cleanImagePath -}} |
| 43 | + |
| 44 | + <!-- Try alternative patterns --> |
| 45 | + {{- $altPath := "img/tests/" -}} |
48 | 46 | {{- $images = resources.Match (printf "%s*" $altPath) -}} |
49 | 47 | {{- $images = where $images "MediaType.MainType" "image" -}} |
50 | | - {{- end -}} |
51 | | - |
52 | | - <!-- If still no images found, try the original path --> |
53 | | - {{- if eq (len $images) 0 -}} |
54 | | - {{- $originalPath := $imagePath -}} |
55 | | - {{- if not (hasSuffix $originalPath "/") -}} |
56 | | - {{- $originalPath = printf "%s/" $originalPath -}} |
| 48 | + |
| 49 | + {{- if gt (len $images) 0 -}} |
| 50 | + {{- warnf "Gallery: Found %d images using fallback path '%s'" (len $images) $altPath -}} |
57 | 51 | {{- end -}} |
58 | | - {{- $images = resources.Match (printf "%s*" $originalPath) -}} |
59 | | - {{- $images = where $images "MediaType.MainType" "image" -}} |
60 | 52 | {{- end -}} |
61 | 53 | {{- end }} |
62 | 54 |
|
|
0 commit comments