Expected solution: The page should show 01 or 02 image, excluding avatar image.
With {% set image = page.media[page.header.primaryImage] ?: page.media.images|filter((v, k) => k != page.header.avatarImage)|first %}
in pages with primaryImage, this is displayed, in pages without primaryImage, any image is displayed. (I've attached some screenshots)
ok, i've tested on a fresh installation of Futura 2021 + latest grav, and change one line (image set), to your last example: {% set image = page.media[page.header.primaryImage] ?: page.media.images|filter((v, k) => k != page.header.avatarImage)|first %}
and everything works fine, so yep
@b.da, following this Github thread, in which @rhuk, explains how to get SVG from page.media, I have made some code modifications that allow to get both images (jpg, png, etc) and SVG files. I think it's not a well optimized code, but it works.
I have used a double ternary operator for it.
Hi @b.da, first of all I want to thank you for your help. The final code works great and is what I wanted.
Second, I want to apologize for not asking the right questions. 😅
It is true that in this post I have asked about the use of SVG as one more requirement, but I thought that when performing a search in the images of a page, it would show all the image files. I've already seen that SVGs are not treated as images, which is why I took advantage of the current query to solve the problem with SVGs.