feat: add `raw_path` parameter to image shortcodes (#439)

main
Óscar 3 months ago committed by GitHub
parent 180fc53384
commit f8e98afd9d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,7 +1,7 @@
+++ +++
title = "Shortcodes personalitzats" title = "Shortcodes personalitzats"
date = 2023-02-19 date = 2023-02-19
updated = 2024-11-07 updated = 2024-11-27
description = "Aquest tema inclou alguns shortcodes personalitzats útils que pots utilitzar per millorar les teves publicacions. Ja sigui per mostrar imatges que s'adapten als temes clar i fosc, o per donar format a una secció de referències amb un aspecte professional, aquests shortcodes personalitzats t'ajudaran." description = "Aquest tema inclou alguns shortcodes personalitzats útils que pots utilitzar per millorar les teves publicacions. Ja sigui per mostrar imatges que s'adapten als temes clar i fosc, o per donar format a una secció de referències amb un aspecte professional, aquests shortcodes personalitzats t'ajudaran."
[taxonomies] [taxonomies]
@ -107,8 +107,9 @@ El teu codi Mermaid va aquí.
Tots els shortcodes d'imatge admeten rutes absolutes, rutes relatives, i fonts remotes en el paràmetre `src`. Tots els shortcodes d'imatge admeten rutes absolutes, rutes relatives, i fonts remotes en el paràmetre `src`.
Tots els shortcodes d'imatge tenen tres paràmetres opcionals: Tots els shortcodes d'imatge tenen els següents paràmetres opcionals:
- `raw_path`. Per defecte és `false`. Si es configura a `true`, el paràmetre `src` s'utilitzarà tal qual. Útil per a actius ubicats a la mateixa carpeta que tenen un slug personalitzat (vegeu [Zola issue #2598](https://github.com/getzola/zola/issues/2598)).
- `inline`. Valor predeterminat: `false`. Si s'estableix a `true`, la imatge es mostrarà en línia amb el text. - `inline`. Valor predeterminat: `false`. Si s'estableix a `true`, la imatge es mostrarà en línia amb el text.
- `full_width`. Valor predeterminat: `false` (vegeu [a sota](#imatge-d-amplada-completa)). - `full_width`. Valor predeterminat: `false` (vegeu [a sota](#imatge-d-amplada-completa)).
- `lazy_loading`. Valor predeterminat: `true`. - `lazy_loading`. Valor predeterminat: `true`.

@ -1,7 +1,7 @@
+++ +++
title = "Shortcodes personalizados" title = "Shortcodes personalizados"
date = 2023-02-19 date = 2023-02-19
updated = 2024-11-07 updated = 2024-11-27
description = "Este tema incluye algunos shortcodes personalizados útiles que puedes utilizar para mejorar tus publicaciones. Puedes mostrar imágenes que se adapten a los temas claro y oscuro, dar formato a una sección de referencias con un aspecto profesional, y más." description = "Este tema incluye algunos shortcodes personalizados útiles que puedes utilizar para mejorar tus publicaciones. Puedes mostrar imágenes que se adapten a los temas claro y oscuro, dar formato a una sección de referencias con un aspecto profesional, y más."
[taxonomies] [taxonomies]
@ -105,8 +105,9 @@ Tu diagrama Mermaid va aquí. Puedes omitir los parámetros para usar los valore
Todos los shortcodes de imagen admiten rutas absolutas, rutas relativas, y fuentes remotas en el parámetro `src`. Todos los shortcodes de imagen admiten rutas absolutas, rutas relativas, y fuentes remotas en el parámetro `src`.
Todos los shortcodes de imagen tienen tres parámetros opcionales: Todos los shortcodes de imagen tienen los siguientes parámetros opcionales:
- `raw_path`. Por defecto es `false`. Si se establece en `true`, el parámetro `src` se usará tal cual. Útil para activos ubicados en la misma carpeta que tienen un slug personalizado (ver [Zola issue #2598](https://github.com/getzola/zola/issues/2598)).
- `inline`. Valor predeterminado: `false`. Si se establece `true`, la imagen se mostrará en línea con el texto. - `inline`. Valor predeterminado: `false`. Si se establece `true`, la imagen se mostrará en línea con el texto.
- `full_width`. Valor predeterminado: `false` (ver [más abajo](#imagen-a-ancho-completo)). - `full_width`. Valor predeterminado: `false` (ver [más abajo](#imagen-a-ancho-completo)).
- `lazy_loading`. Valor predeterminado: `true`. - `lazy_loading`. Valor predeterminado: `true`.

@ -1,7 +1,7 @@
+++ +++
title = "Custom shortcodes" title = "Custom shortcodes"
date = 2023-02-19 date = 2023-02-19
updated = 2024-11-07 updated = 2024-11-27
description = "This theme includes some useful custom shortcodes that you can use to enhance your posts. Whether you want to display images that adapt to light and dark themes, or format a professional-looking reference section, these custom shortcodes have got you covered." description = "This theme includes some useful custom shortcodes that you can use to enhance your posts. Whether you want to display images that adapt to light and dark themes, or format a professional-looking reference section, these custom shortcodes have got you covered."
[taxonomies] [taxonomies]
@ -107,8 +107,9 @@ Your diagram goes here.
All image shortcodes support absolute paths, relative paths, and remote sources in the `src` parameter. All image shortcodes support absolute paths, relative paths, and remote sources in the `src` parameter.
All image shortcodes have three optional parameters: All image shortcodes have these optional parameters:
- `raw_path`. Defaults to `false`. If set to `true`, the `src` parameter will be used as is. Useful for colocated assets with a custom slug (see [Zola issue #2598](https://github.com/getzola/zola/issues/2598)).
- `inline`. Defaults to `false`. If set to `true`, the image will be displayed inline with the text. - `inline`. Defaults to `false`. If set to `true`, the image will be displayed inline with the text.
- `full_width`. Defaults to `false` (see [below](#full-width-image)) - `full_width`. Defaults to `false` (see [below](#full-width-image))
- `lazy_loading`. Defaults to `true`. - `lazy_loading`. Defaults to `true`.

@ -1,5 +1,5 @@
{#- Determine image path based on whether the src is remote or local -#} {#- Determine image path based on whether the src is remote or local -#}
{%- if src is starting_with("http") -%} {%- if src is starting_with("http") or raw_path -%}
{%- set image_url = src -%} {%- set image_url = src -%}
{%- else -%} {%- else -%}
{%- set colocated_path = page.colocated_path | default(value="") -%} {%- set colocated_path = page.colocated_path | default(value="") -%}

@ -10,7 +10,7 @@
{%- endif -%} {%- endif -%}
{# Handling for light mode image #} {# Handling for light mode image #}
{%- if light_src is starting_with("http") -%} {%- if light_src is starting_with("http") or raw_path -%}
{%- set light_image_url = light_src -%} {%- set light_image_url = light_src -%}
{%- else -%} {%- else -%}
{%- set relative_light_path = colocated_path ~ light_src -%} {%- set relative_light_path = colocated_path ~ light_src -%}
@ -23,7 +23,7 @@
{%- endif -%} {%- endif -%}
{# Handling for dark mode image #} {# Handling for dark mode image #}
{%- if dark_src is starting_with("http") -%} {%- if dark_src is starting_with("http") or raw_path -%}
{%- set dark_image_url = dark_src -%} {%- set dark_image_url = dark_src -%}
{%- else -%} {%- else -%}
{%- set relative_dark_path = colocated_path ~ dark_src -%} {%- set relative_dark_path = colocated_path ~ dark_src -%}

@ -1,5 +1,5 @@
{#- Set paths based on whether the src is remote or local -#} {#- Set paths based on whether the src is remote or local -#}
{%- if src is starting_with("http") -%} {%- if src is starting_with("http") or raw_path -%}
{%- set image_url = src -%} {%- set image_url = src -%}
{%- else -%} {%- else -%}
{%- set colocated_path = page.colocated_path | default(value="") -%} {%- set colocated_path = page.colocated_path | default(value="") -%}

@ -15,7 +15,7 @@
{%- endif -%} {%- endif -%}
{#- Direct or relative URL handling for default image -#} {#- Direct or relative URL handling for default image -#}
{%- if default_src is starting_with("http") -%} {%- if default_src is starting_with("http") or raw_path -%}
{%- set default_image_url = default_src -%} {%- set default_image_url = default_src -%}
{%- else -%} {%- else -%}
{%- set relative_default_path = colocated_path ~ default_src -%} {%- set relative_default_path = colocated_path ~ default_src -%}
@ -28,7 +28,7 @@
{%- endif -%} {%- endif -%}
{#- Direct or relative URL handling for hovered image -#} {#- Direct or relative URL handling for hovered image -#}
{%- if hovered_src is starting_with("http") -%} {%- if hovered_src is starting_with("http") or raw_path -%}
{%- set hovered_image_url = hovered_src -%} {%- set hovered_image_url = hovered_src -%}
{%- else -%} {%- else -%}
{%- set relative_hovered_path = colocated_path ~ hovered_src -%} {%- set relative_hovered_path = colocated_path ~ hovered_src -%}

@ -19,7 +19,7 @@
{%- endif -%} {%- endif -%}
{# Direct or relative URL handling for default image #} {# Direct or relative URL handling for default image #}
{%- if default_src is starting_with("http") -%} {%- if default_src is starting_with("http") or raw_path -%}
{%- set default_image_url = default_src -%} {%- set default_image_url = default_src -%}
{%- else -%} {%- else -%}
{%- set relative_default_path = colocated_path ~ default_src -%} {%- set relative_default_path = colocated_path ~ default_src -%}
@ -32,7 +32,7 @@
{%- endif -%} {%- endif -%}
{# Direct or relative URL handling for toggled image #} {# Direct or relative URL handling for toggled image #}
{%- if toggled_src is starting_with("http") -%} {%- if toggled_src is starting_with("http") or raw_path -%}
{%- set toggled_image_url = toggled_src -%} {%- set toggled_image_url = toggled_src -%}
{%- else -%} {%- else -%}
{%- set relative_toggled_path = colocated_path ~ toggled_src -%} {%- set relative_toggled_path = colocated_path ~ toggled_src -%}

@ -1,5 +1,5 @@
{#- Determine if src is a remote URL or a local path -#} {#- Determine if src is a remote URL or a local path -#}
{%- if src is starting_with("http") -%} {%- if src is starting_with("http") or raw_path -%}
{%- set image_url = src -%} {%- set image_url = src -%}
{%- else -%} {%- else -%}
{%- set colocated_path = page.colocated_path | default(value="") -%} {%- set colocated_path = page.colocated_path | default(value="") -%}

Loading…
Cancel
Save