Cms image driven

trying using images to control look, still working on my blog layout still a way to go til I get what I want, anyway if of interest, the twig etc file has additional stuff now

im ignoring the single blog page at the moment

2 Likes

That’s great @upssjw thanks for sharing.

what if you wanted your blog as a modal menu

same as above but with modal, same blog different page, on page blog list, the other modal blog list

project

elementsapp://downloadDocument/38M2ansnoUl1

still testing but a little more neater

not sure if this will break one page blog, container and item same page, arrgghh

might break - one page blog

project

elementsapp://downloadDocument/zErYkndP08Va

just check modal cms works, https://sjwjaw.co.uk Blogdd and Easyflex

again just proof of concept

the home page is just entry, not in menu

two blog pages same md files

did say last go but could not resist, definitely last go with this design, still not what I want

3 blogs related and search included, featured on first blog, hopefully still works, one is blog on a page

project - elementsapp://downloadDocument/YEGu41Y51ckR

again remove late tonight

updated project, blog on a page works fine in Elements, but when uploaded I had to tweak the page address to get the blog to load on first entry, otherwise you get a no item found

this has collection and item components on same page - this might get broken with Elements updates

https://sjwjaw.co.uk BlogSP appears to now load with a blog showing

updated project

I just hid the BlogSP as it was already setup, created a link in the menu and directed it to one of the blogs, in this case

https://sjwjaw.co.uk/blogsp/?item=today

Checking on the server highlights a couple of areas need tweaking, not that I will use any of this

ok random image from markdown file works, only have set four images, they are almost all the same in each blog so no real visual effect, bonus, all Elements and CMS

using this code in the image cms, and pulling the image: eg img1 etc from the markdown, all my markdowns have the same images, not tried on server yet, just add more img’s for more choice, or use in single Item page

project - elementsapp://downloadDocument/1SJgV8kN3yJv

just keep refreshing

proof of concept works on server - page randimg

CMS is fairly powerful even at this stage, addicted now to CMS

simple use of CMS to create a random background on load, very basic setup, no blog just random image, only Elements, so many uses, 5 mins work not fully tested will check more after work today

project - elementsapp://downloadDocument/LxeeXuUCueQV

checked on server, just refresh page, definitely now finished with this concept, will remove tonight

https://sjwjaw.co.uk/contact/

use of CMS different take

global menu background cms driven, random images on load

project - elementsapp://downloadDocument/nq9ylTFh55jF

live site -https://sjwjaw.co.uk/cmsdata/

@Steve

I’m trying to achieve something similar to this pattern

{{ item.image.src | default(item.image.fallback_image) }}

The idea is that the fallback image should always be rendered whenever no image is defined in the blog post .

Unfortunately, this doesn’t work the same way as it does with text fields.

For text, the default filter behaves exactly as expected — but for images it doesn’t, at least not in my current setup.

It seems that Twig does not fully support this syntax for image objects yet, or the image field itself is not resolved as a simple scalar value (like a string), which causes the fallback logic to fail.

That’s why your suggested variant is interesting to me.

This approach works because it directly targets a string value (the image URL), instead of the image object itself. As a result, the default filter can properly evaluate whether the value is empty or missing and then fall back as intended.

I’m going to take a closer look at your solution — it might actually be the right workaround for this limitation.

At the very least, it looks like a solid and pragmatic approach until image fields support the same fallback behavior as text fields.

I have tried lots of things image related some work some dont

still playing with the code I have used, not sure or tried might be able to tweak the code

https://twig.symfony.com/doc/3.x/functions/attribute.html

Warning

also been working with shuffle and an array

the large image on the contact page is an array and shuffle a lot shorter code should be able to add fallback?

the rest of the images are cms random

live site - https://sjwjaw.co.uk/cmsdata/

project - elementsapp://downloadDocument/LLRYj53WrWWt