* feat(image-zoom): add image zoom functionality and documentation - Introduced a new `imageZoom` parameter in the configuration to enable click-to-zoom for Markdown images. - Updated the `render-image.html` layout to support zoom functionality by adding a `data-zoomable` attribute to images. - Created a new `medium-zoom.html` script to handle the zoom effect, with options for CDN or local asset loading. - Enhanced documentation in `configuration.md` and `markdown.md` to guide users on enabling and configuring image zoom. * docs(image-zoom): add image zoom documentation in multiple languages - Added sections for image zoom functionality in Persian, Japanese, and Simplified Chinese documentation. - Included configuration examples for enabling and disabling image zoom in specific pages. - Updated related documentation to ensure consistency across languages.
52 lines
2.1 KiB
HTML
52 lines
2.1 KiB
HTML
{{- $alt := .PlainText | safeHTML -}}
|
|
{{- $lazyLoading := .Page.Site.Params.enableImageLazyLoading | default true -}}
|
|
{{- $enableImageZoom := .Page.Site.Params.imageZoom.enable | default false -}}
|
|
{{- if not (eq .Page.Params.imageZoom nil) -}}
|
|
{{- $enableImageZoom = .Page.Params.imageZoom -}}
|
|
{{- end -}}
|
|
{{- $dest := .Destination -}}
|
|
{{- $url := urls.Parse $dest -}}
|
|
|
|
{{- $isLocal := not $url.Scheme -}}
|
|
{{- $isPage := and (eq .Page.Kind "page") (not .Page.BundleType) -}}
|
|
{{- $startsWithSlash := hasPrefix $dest "/" -}}
|
|
{{- $startsWithRelative := hasPrefix $dest "../" -}}
|
|
|
|
{{- if and $dest $isLocal -}}
|
|
{{- if $startsWithSlash -}}
|
|
{{- with or (.PageInner.Resources.Get $url.Path) (resources.Get $url.Path) -}}
|
|
{{/* Images under assets directory */}}
|
|
{{- $query := cond $url.RawQuery (printf "?%s" $url.RawQuery) "" -}}
|
|
{{- $fragment := cond $url.Fragment (printf "#%s" $url.Fragment) "" -}}
|
|
{{- $dest = printf "%s%s%s" .RelPermalink $query $fragment -}}
|
|
{{- else -}}
|
|
{{/* Images under static directory */}}
|
|
{{- $dest = (relURL (strings.TrimPrefix "/" $dest)) -}}
|
|
{{- end -}}
|
|
{{- else if and $isPage (not $startsWithRelative) -}}
|
|
{{/* Images that are sibling to the individual page file */}}
|
|
{{ $dest = (printf "../%s" $dest) }}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- $attributes := "" -}}
|
|
{{- range $key, $value := .Attributes -}}
|
|
{{- if $value -}}
|
|
{{- $pair := printf "%s=%q" $key ($value | transform.HTMLEscape) -}}
|
|
{{- $attributes = printf "%s %s" $attributes $pair -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- if $enableImageZoom -}}
|
|
{{- .Page.Store.Set "hasImageZoom" true -}}
|
|
{{- end -}}
|
|
|
|
{{- with .Title -}}
|
|
<figure>
|
|
<img src="{{ $dest | safeURL }}" title="{{ . }}" alt="{{ $alt }}" {{ $attributes | safeHTMLAttr }}{{ if $enableImageZoom }} data-zoomable{{ end }}{{ if $lazyLoading }} loading="lazy"{{ end }} />
|
|
<figcaption>{{ . }}</figcaption>
|
|
</figure>
|
|
{{- else -}}
|
|
<img src="{{ $dest | safeURL }}" alt="{{ $alt }}" {{ $attributes | safeHTMLAttr }}{{ if $enableImageZoom }} data-zoomable{{ end }}{{ if $lazyLoading }} loading="lazy"{{ end }} />
|
|
{{- end -}}
|