diff --git a/modules/blox/blox/cta-image-paragraph/block.html b/modules/blox/blox/cta-image-paragraph/block.html index 03901651..8907f8b3 100644 --- a/modules/blox/blox/cta-image-paragraph/block.html +++ b/modules/blox/blox/cta-image-paragraph/block.html @@ -28,15 +28,47 @@ {{ $image_name := "" }} {{ $image_raw := index $item "image" }} {{ if eq (printf "%T" $image_raw) "string" }}{{ $image_name = strings.TrimSpace $image_raw }}{{ end }} - {{ $image_path := "" }} - {{ if $image_name }}{{ $image_path = path.Join "media" $image_name }}{{ end }} - {{ $image := "" }} - {{ if $image_path }}{{ $image = resources.GetMatch $image_path }}{{ end }} - {{ if $image }} + {{/* Resolve image from page bundle, site assets, remote, or static URLs */}} + {{ $image_resource := false }} + {{ $image_url := "" }} + {{ if $image_name }} + {{ $image_path := strings.TrimSpace (printf "%v" $image_name) }} + {{ $is_remote := or (strings.HasPrefix $image_path "http://") (strings.HasPrefix $image_path "https://") }} + + {{ if $is_remote }} + {{ $remote := try (resources.GetRemote $image_path) }} + {{ if and $remote (not $remote.Err) }} + {{ $image_resource = $remote.Value }} + {{ else }} + {{ $image_url = $image_path }} + {{ end }} + {{ else }} + {{ $image_path = strings.TrimPrefix "/" $image_path }} + {{ $image_path = strings.TrimPrefix "./" $image_path }} + {{ $image_path = strings.TrimPrefix "assets/" $image_path }} + {{ $image_path = strings.TrimPrefix "media/" $image_path }} + {{ $normalized := path.Clean $image_path }} + + {{ if and $normalized (ne $normalized ".") }} + {{ with $page }} + {{ $image_resource = (.Resources.ByType "image").GetMatch $normalized }} + {{ end }} + {{ if not $image_resource }} + {{ $image_resource = resources.Get (path.Join "media" $normalized) }} + {{ end }} + {{ if not $image_resource }} + {{ $image_url = printf "/media/%s" $normalized }} + {{ end }} + {{ end }} + {{ end }} + {{ end }} + + {{ $image_to_render := $image_resource }} + {{ if $image_to_render }}
- {{ if ne $image.MediaType.SubType "gif" }} + {{ if ne $image_to_render.MediaType.SubType "gif" }} {{ $responsive := partial "functions/process_responsive_image.html" (dict - "image" $image + "image" $image_to_render "mode" "fit" "sizes" (slice 400 600 800 1200) ) }} @@ -49,11 +81,18 @@ alt="{{$title | plainify}}" {{ if (modBool $idx 2)}}style="order: 1"{{end}}> {{ else }} {{$title | plainify}} {{ end }} + {{ else if $image_url }} +
+ {{ $is_external := or (strings.HasPrefix $image_url "http://") (strings.HasPrefix $image_url "https://") }} + {{$title | plainify}} + {{ end }} {{ else }} {{ warnf "%s uses the `cta-image-paragraph` blox which specifies a non-existent `image` at `assets/%s`. Skipping this item." $page.File.Path $image_path }} {{ end }} diff --git a/modules/blox/blox/logos/block.html b/modules/blox/blox/logos/block.html index 569f9f35..71e2424c 100644 --- a/modules/blox/blox/logos/block.html +++ b/modules/blox/blox/logos/block.html @@ -111,9 +111,43 @@
{{ end }}
+ {{/* Logo Image */}} {{/* Logo Image */}} {{ if $image_name }} - {{ $img := resources.Get (printf "media/%s" $image_name) }} + {{/* Resolve image from page bundle, site assets, remote, or static URLs */}} + {{ $image_resource := false }} + {{ $image_url := "" }} + {{ $image_path := strings.TrimSpace (printf "%v" $image_name) }} + {{ $is_remote := or (strings.HasPrefix $image_path "http://") (strings.HasPrefix $image_path "https://") }} + + {{ if $is_remote }} + {{ $remote := try (resources.GetRemote $image_path) }} + {{ if and $remote (not $remote.Err) }} + {{ $image_resource = $remote.Value }} + {{ else }} + {{ $image_url = $image_path }} + {{ end }} + {{ else }} + {{ $image_path = strings.TrimPrefix "/" $image_path }} + {{ $image_path = strings.TrimPrefix "./" $image_path }} + {{ $image_path = strings.TrimPrefix "assets/" $image_path }} + {{ $image_path = strings.TrimPrefix "media/" $image_path }} + {{ $normalized := path.Clean $image_path }} + + {{ if and $normalized (ne $normalized ".") }} + {{ with $page }} + {{ $image_resource = (.Resources.ByType "image").GetMatch $normalized }} + {{ end }} + {{ if not $image_resource }} + {{ $image_resource = resources.Get (path.Join "media" $normalized) }} + {{ end }} + {{ if not $image_resource }} + {{ $image_url = printf "/media/%s" $normalized }} + {{ end }} + {{ end }} + {{ end }} + + {{ $img := $image_resource }} {{ if $img }} {{ $isSVG := eq $img.MediaType.SubType "svg" }} {{ if not $isSVG }} @@ -124,6 +158,12 @@ {{ if not $isSVG }}width="{{ $img.Width }}" height="{{ $img.Height }}"{{ end }} class="h-12 sm:h-14 lg:h-16 w-auto mx-auto object-contain filter grayscale opacity-60 group-hover:grayscale-0 group-hover:opacity-100 transition-all duration-300 group-hover:scale-110" loading="lazy"> + {{ else if $image_url }} + {{ $is_external := or (strings.HasPrefix $image_url "http://") (strings.HasPrefix $image_url "https://") }} + {{ $name | default {{ end }} {{ end }} diff --git a/modules/blox/blox/research-areas/block.html b/modules/blox/blox/research-areas/block.html index da557884..6c9a6498 100644 --- a/modules/blox/blox/research-areas/block.html +++ b/modules/blox/blox/research-areas/block.html @@ -176,12 +176,49 @@ {{/* Card Image/Icon Header */}} {{ $header_content := "" }} {{ if $image }} - {{ $image_path := strings.TrimPrefix $image "/" }} - {{ $img := resources.Get (printf "media/%s" $image_path) }} + {{/* Resolve image from page bundle, site assets, remote, or static URLs */}} + {{ $image_resource := false }} + {{ $image_url := "" }} + {{ $image_path := strings.TrimSpace (printf "%v" $image) }} + {{ $is_remote := or (strings.HasPrefix $image_path "http://") (strings.HasPrefix $image_path "https://") }} + + {{ if $is_remote }} + {{ $remote := try (resources.GetRemote $image_path) }} + {{ if and $remote (not $remote.Err) }} + {{ $image_resource = $remote.Value }} + {{ else }} + {{ $image_url = $image_path }} + {{ end }} + {{ else }} + {{ $image_path = strings.TrimPrefix "/" $image_path }} + {{ $image_path = strings.TrimPrefix "./" $image_path }} + {{ $image_path = strings.TrimPrefix "assets/" $image_path }} + {{ $image_path = strings.TrimPrefix "media/" $image_path }} + {{ $normalized := path.Clean $image_path }} + + {{ if and $normalized (ne $normalized ".") }} + {{ with $page }} + {{ $image_resource = (.Resources.ByType "image").GetMatch $normalized }} + {{ end }} + {{ if not $image_resource }} + {{ $image_resource = resources.Get (path.Join "media" $normalized) }} + {{ end }} + {{ if not $image_resource }} + {{ $image_url = printf "/media/%s" $normalized }} + {{ end }} + {{ end }} + {{ end }} + + {{ $img := $image_resource }} {{ if $img }} {{ $img = $img.Fill "600x400 Center webp" }} {{ $alt := $name | plainify }} {{ $header_content = printf "\"%s\"" $img.RelPermalink $alt }} + {{ else if $image_url }} + {{ $alt := $name | plainify }} + {{ $is_external := or (strings.HasPrefix $image_url "http://") (strings.HasPrefix $image_url "https://") }} + {{ $src := cond $is_external $image_url ($image_url | relURL) }} + {{ $header_content = printf "\"%s\"" $src $alt }} {{ end }} {{ else if $icon }} {{ $icon_html := partial "functions/get_icon" (dict "name" $icon "attributes" "class=\"w-24 h-24 text-white/80 group-hover:scale-110 transition-transform duration-300\"") }} diff --git a/modules/blox/blox/resume-biography-3/block.html b/modules/blox/blox/resume-biography-3/block.html index e615b4f4..3a96d1de 100644 --- a/modules/blox/blox/resume-biography-3/block.html +++ b/modules/blox/blox/resume-biography-3/block.html @@ -92,32 +92,74 @@ {{/* Banner Image */}} {{ $img := "" }} + {{/* Resolve image from page bundle, site assets, remote, or static URLs */}} + {{ $image_resource := false }} + {{ $image_url := "" }} + {{ if $banner_filename }} - {{- $img = resources.Get (path.Join "media" $banner_filename) -}} - {{ if $img }} -
- {{ if ne $img.MediaType.SubType "gif" }} - {{ $responsive := partial "functions/process_responsive_image.html" (dict - "image" $img - "mode" "fill" - "aspect_ratio" "16:9" - "sizes" (slice 768 1024 1366 1920 2560) - ) }} - - {{ else }} - {{- $img = $img.Process "webp" -}} - + {{ $image_path := strings.TrimSpace (printf "%v" $banner_filename) }} + {{ $is_remote := or (strings.HasPrefix $image_path "http://") (strings.HasPrefix $image_path "https://") }} + + {{ if $is_remote }} + {{ $remote := try (resources.GetRemote $image_path) }} + {{ if and $remote (not $remote.Err) }} + {{ $image_resource = $remote.Value }} + {{ else }} + {{ $image_url = $image_path }} + {{ end }} + {{ else }} + {{ $image_path = strings.TrimPrefix "/" $image_path }} + {{ $image_path = strings.TrimPrefix "./" $image_path }} + {{ $image_path = strings.TrimPrefix "assets/" $image_path }} + {{ $image_path = strings.TrimPrefix "media/" $image_path }} + {{ $normalized := path.Clean $image_path }} + + {{ if and $normalized (ne $normalized ".") }} + {{ with $page }} + {{ $image_resource = (.Resources.ByType "image").GetMatch $normalized }} {{ end }} -
+ {{ if not $image_resource }} + {{ $image_resource = resources.Get (path.Join "media" $normalized) }} + {{ end }} + {{ if not $image_resource }} + {{ $image_url = printf "/media/%s" $normalized }} + {{ end }} + {{ end }} {{ end }} {{ end }} + {{ $img = $image_resource }} + + {{ if $img }} +
+ {{ if ne $img.MediaType.SubType "gif" }} + {{ $responsive := partial "functions/process_responsive_image.html" (dict + "image" $img + "mode" "fill" + "aspect_ratio" "16:9" + "sizes" (slice 768 1024 1366 1920 2560) + ) }} + + {{ else }} + {{- $img = $img.Process "webp" -}} + + {{ end }} +
+ {{ else if $image_url }} + {{ $is_external := or (strings.HasPrefix $image_url "http://") (strings.HasPrefix $image_url "https://") }} +
+ +
+ {{ end }} + {{/* Avatar */}} {{ $status_icon := "" }} {{ $status := $profile.status }} diff --git a/modules/blox/blox/resume-biography/block.html b/modules/blox/blox/resume-biography/block.html index 8e0dcc61..31339af9 100644 --- a/modules/blox/blox/resume-biography/block.html +++ b/modules/blox/blox/resume-biography/block.html @@ -57,8 +57,52 @@ {{ with index $banner "filename" }}{{ $banner_filename = strings.TrimSpace (printf "%v" .) }}{{ end }} {{ end }} {{ if $banner_filename }} - {{ $banner_path := strings.TrimPrefix $banner_filename "/" }} - {{- $img = resources.Get (path.Join "media" $banner_path) -}} +{{ $banner_path := strings.TrimPrefix "/" $banner_filename }} + {{/* Resolve image from page bundle, site assets, remote, or static URLs */}} + {{ $image_resource := false }} + {{ $image_url := "" }} + + {{ if $banner_filename }} + {{ $image_path := strings.TrimSpace (printf "%v" $banner_filename) }} + {{ $is_remote := or (strings.HasPrefix $image_path "http://") (strings.HasPrefix $image_path "https://") }} + + {{ if $is_remote }} + {{ $remote := try (resources.GetRemote $image_path) }} + {{ if and $remote (not $remote.Err) }} + {{ $image_resource = $remote.Value }} + {{ else }} + {{/* If remote fetch fails, fall back to the original URL */}} + {{ $image_url = $image_path }} + {{ end }} + {{ else }} + {{/* Normalize common prefixes and dot paths */}} + {{ $image_path = strings.TrimPrefix "/" $image_path }} + {{ $image_path = strings.TrimPrefix "./" $image_path }} + {{ $image_path = strings.TrimPrefix "assets/" $image_path }} + {{ $image_path = strings.TrimPrefix "media/" $image_path }} + {{ $normalized := path.Clean $image_path }} + + {{ if and $normalized (ne $normalized ".") }} + {{/* Prefer page bundle image resources */}} + {{ with $page }} + {{ $image_resource = (.Resources.ByType "image").GetMatch $normalized }} + {{ end }} + + {{ if not $image_resource }} + {{/* Look in global assets/media - use resources.Get for exact path matching */}} + {{ $image_resource = resources.Get (path.Join "media" $normalized) }} + {{ end }} + + {{ if not $image_resource }} + {{/* Static fallback (serves original size) */}} + {{ $image_url = printf "/media/%s" $normalized }} + {{ end }} + {{ end }} + {{ end }} + {{ end }} + + {{ $img = $image_resource }} + {{ if $img }} {{ if ne $img.MediaType.SubType "gif" }} {{ $responsive := partial "functions/process_responsive_image.html" (dict @@ -94,6 +138,18 @@
{{ end }} + {{ else if $image_url }} + {{/* Static fallback for remote/unprocessed images */}} + {{ $is_external := or (strings.HasPrefix $image_url "http://") (strings.HasPrefix $image_url "https://") }} +
+
+
+ +
+
+
{{ end }} {{ end }}