0

No idea if this is possible. I currently have an entry setup, that if an image is uploaded, it will appear at the bottom of the page, in a 'gallery' format below a heading, being: Gallery: Click to enlarge.

Now if the uploaded image is set as a 'cover' image, it will appear at the top right of the page (right of the text) instead of at the bottom (gallery) of the page.

This works fine, see code:

(This appears at the top of the page)

{exp:channel_images:images entry_id="{entry_id}" limit="1" cover_only="yes" force_cover="yes"}
...my image...
{/exp:channel_images:images}

(This appears at the bottom of the page)

{if news_image}

<div class="gal">
<h4>Gallery: Click to enlarge</h4>
{exp:channel_images:images entry_id="{entry_id}" skip_cover="yes"}
...my image(s)... (appearing within individual divs)
{/exp:channel_images:images}
</div>

{/if}

Because my 'if' statement just looks to see if an image exists, the Div AND the H4 heading still appear at the bottom of the page, even if the image is set as 'cover'.

So, is it possible to customise the 'if' statement so that my html code (div/h4 ) will ALSO not appear (when the image is set as cover).

Any help is appreciated. (I understand that this is not necessarily a channel images question).

3

Here is what you want to do.

    {if news_image}
      {exp:channel_images:images entry_id="{entry_id}" skip_cover="yes"}
        {!-- only opening HTML data on the first loop --}
        {if "{image:count}" == "1"}
          <div class="gal">
          <h4>Gallery: Click to enlarge</h4>
        {/if}

        ...my image(s)... (appearing within individual divs)

        {!-- Closes HTML data on the last loop --}
        {if "{image:count}" == "{image:total}"}
          </div>
        {/if}
      {/exp:channel_images:images}
    {/if}
| improve this answer | |
  • THANK YOU so much for this, absolutely perfect. Much appreciated! – ZEDG Jul 5 '14 at 9:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.