10
ACF Item - Placholder image if empty value
I’ve got a situation, where I am using an Advanced Custom Field (ACF) to upload an image so that I can display a picture of a report for the post.
However, sometimes it’s not possible to upload an image for each an every post, and I would like to be able to use a placeholder image if no image has been uploaded (empty value).
This would save a lot of time having to select a ‘placeholder image’ from the media library for every post to ensure I can have something to display on the front end (rather than an empty space).
Upvoters
10
Feature Details
Status:
Board: Divi Machine
Created: 18 July 2024
Last Updated: 18 July 2024
Posted By: VolumeDean
Join the conversion, Login to Reply
VolumeDean - 18 July 2024
Thank you @Ruud - I will investigate the links and info you have posted to see if I can get something working. Thanks for taking the time to reply.
Ruud - 18 July 2024
There is also an ACF filter/function you can add. See the following links:
https://support.advancedcustomfields.com/forums/topic/default-value-for-images/
https://github.com/Hube2/acf-filters-and-functions
https://github.com/Hube2/acf-filters-and-functions/blob/master/default-image-for-image-field.php
Ruud - 18 July 2024
I think that should already be possible with the build-in Divi Display Only If Condition on the advanced tab. Make one element with the placeholder image displaying only when the acf has an empty value and another element with the dynamic content linking to the uploaded image when the acf has a value.