Support

Account

Home Forums ACF PRO Image-Not-Available option Reply To: Image-Not-Available option

  • Hi stinkykong,

    You may do any of the above. I would suggest creating an additional field for the ‘alt image’, so that changing the alt image URL down the road would not require any code changes.

    Where you might wish to store this additional field is up to you. You might choose to make it a site-wide option and store it on an ACF Options Page, or make it more flexible by assigning it to a hierarchical taxonomy, such as the Post Category.

    Take a look at the acf_add_options_page documentation and How to get values from an options page.

    To test a field’s existence, you may do something like this:

    
    <?php
    
    $my_img_url = get_field('image-field-name-or-key');
    if ( !$my_img_url ) {
        $my_img_url = get_field('default-image-field-name-or-key', 'option');
        // ProTip: You may want to also check here if the option page default image hasn't been set either!
    }
    
    // Use $my_img_url here
    
    ?>
    

    HTH 🙂

    ————————

    Help your fellow forum-goers and moderation team; if a response solves your problem, please mark it as the solution. Thank you!