Open phmg701 opened 4 years ago
metadata is expected in a flat array, not a nested data currently.
Further investigation lead to this conclusion, so I managed to manually recreate the <img>
tag without errors:
<img src="{{image.resize(640, 640).url}}"></img>
For multilanguage metadata I played around with bi-dimensional arrays this way (with checks and fallbacks):
{% if config.theme.imagemeta.enabled %}
{% for mf in config.theme.imagemeta.fields %}
{% if mf.enabled and (not image.meta[mf.meta_field] is null or not image.meta[mf.meta_field][lang] is null) %}
<p class="mg-metadata mg-meta-{{mf.meta_field}}">{% if not image.meta[mf.meta_field][lang] is null %}{{image.meta[mf.meta_field][lang]}}{% else %}{{image.meta[mf.meta_field]}}{% endif %}</p>
{% endif %}
{% endfor %}
{% endif %}
The next big step is to centralize Images in a folder and work/filter them as a database, even by tag in .meta file. I still have to dig deep into Grav's Flex Objects, it might be an option.
Thanks
Hello, really nice work with Grav! I chose it on top of many other CMSs because:
is lean, fast and DB-less
has native multilanguage support troughout the system
has modular pages OOB
YAML-everything (wow!)
I am trying to build a template/gallery module starting from the Cookbook recipe but when I add, in imageX.meta.yaml the following:
Twig engine crashes as, for what I understand from debug bar and Clockwork, multilanguage meta is stored inside an array and Twig/Grav expects a string.
Is there a workaround for supporting multi language metadata for images? It would be a great addition to the already excellent language support in Grav!
Thank you