Skip Navigation

[Resolved] Conditional if empty?

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 8 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 1 reply, has 2 voices.

Last updated by Beda 8 years, 3 months ago.

Assisted by: Beda.

Author
Posts
#425751

I am trying to:
Display a default image if the user hasn't uploaded their own image.
I have followed support forum entries where '' should mean 'empty' but doesnt seem to work with images.

The below always returns the second one, meaning empty, when they are not. I've tried 'ne' instead and swapping them around. Basically I cannot test if an image is present or not, returns TRUE always for: eq '', even when there is an image.

[wpv-conditional if="( $(wpcf-image-gallery) ne '' )" ]
<div class=" bvimage_gallery_card hasimage" >
<img src="[types field='image-gallery' size='medium' url='true' resize='crop' separator=' ' id='$business-venues'][/types]"/>
</div>
[/wpv-conditional]

[wpv-conditional if="( $(wpcf-image-gallery) eq '' )" ]
<div class="bvimage_gallery_card noimage" ><img src="/noimage.png" /></div>
[/wpv-conditional]

#425762

Please use the GUI "Conditional Display" to create Conditions.

This will create it correctly.

As example, if I have a Types Image Field, and upload an Image to it, this code below will show it:

[wpv-conditional if="( $(wpcf-image) ne '' )"]
  [types field='image' size='full' align='none'][/types]
[/wpv-conditional]

This Code above will NOT show the image if there is none, and similarly I can then output a placeholder in the case no image exists:

[wpv-conditional if="( $(wpcf-image) eq '' )"]
  PLACEHOLDER
[/wpv-conditional]

This works fine, I tested this locally.

Can you try again by using the GUI?

The forum ‘Types Community Support’ is closed to new topics and replies.