Skip Navigation

[Resolved] Setting a default image for display

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a custom image field and I would like to display a default image if the field has no value.

Solution: Use a series of conditional blocks to display a default image if the field is empty or display the custom field image if the field has some value.

Relevant Documentation:
https://toolset.com/course-lesson/using-toolset-conditional-block/

This support ticket is created 3 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by JoshuaD7497 3 years, 5 months ago.

Assisted by: Christian Cox.

Author
Posts
#2085323

My website lists musical concerts.

I have added an 'Image' field to the concert post type for the concert poster.

On the front end, I'm using a View to output the concerts, including the poster image.

Some of the concerts are very old and a poster image is not always available. Where a concert poster has not been added, I would like to display a default/fallback image.

I have tried adding the URL to the fallback image into the Placeholder box for the field but this has no effect at all.

How do I do this? I'm using the Blocks Views and can't find any way. There are many support threads which cover similar subjects but these seem to all involve coding (and are quite old posts).

Is there an easy way to do this? I would have thought this is a common requirement.

#2086771
Screen Shot 2021-06-13 at 1.49.13 PM.png
Screen Shot 2021-06-13 at 1.49.04 PM.png

Hello, I think in this case I would use a conditional block that tests the value of the custom image field. If the field has no value, display a predefined image. If the field has a value, display the custom field. I'm attaching screenshots showing similar conditionals testing the value of a custom field image. If the value is Empty, display an image field with your default image. If the value is not empty, display the custom field image.

Will this work for your case?

#2088069

Thanks for pointing me in the right direction. The video tutorial at https://toolset.com/course-lesson/using-toolset-conditional-block/ talked me through precisely how to add a different image if the field was empty. Much appreciated.