Problems, need help? Have a tip or advice? Post it here.
2 posts Page 1 of 1
So I am currently integrating Couch with my new website and in order to accommodate varying numbers of images on a page I inserted 6 image fields within couch.My question is when these fields are left blank is there any way of hiding the content completely?

When developing the site before integrating couch this wasn't a problem as the blank div tag contained zero pixels so was essentially void.

e.g.
<div id="grid_content"><img src="img/image1.jpeg" class="staticimg"></div>

However, when intergrating the Couch field:

<div id="grid_content"><img src="<cms:show project_image1 />" class="staticimg"></div>

Leaving the empty field blank leaves a small white box in its place instead of disappearing. Hopefully this makes sense... Does anyone have any suggestions or workarounds?

P.S. I have attatched an image of how the small white boxes appear.

Attachments

Hello and welcome Dan :)

We can first check if an image is set before using it e.g. as follows -
Code: Select all
<cms:if project_image1>
    <div id="grid_content"><img src="<cms:show project_image1 />" class="staticimg"></div>
</cms:if>


As an aside, when using a variable number of images, Repeatable Regions almost always seem to be a better solution - http://docs.couchcms.com/concepts/repea ... gions.html

Hope it helps.
2 posts Page 1 of 1