Support

Account

Home Forums General Issues get_field() — noob problems with Brizy Reply To: get_field() — noob problems with Brizy

  • If you can setup a field, then you can do something like:

    <?php $image = get_field('image');
    if( !empty( $image ) ): ?>
        <img src="<?php echo esc_url($image['url']); ?>" alt="<?php echo esc_attr($image['alt']); ?>" />
    <?php endif; ?>

    You would need to change the field name from image to whatever you need.

    Or you could do something like:

    <?php $image = get_field('image');
    if( !empty( $image ) ): ?>
        <img src="<?php echo esc_url($image['url']); ?>" alt="<?php echo esc_attr($image['alt']); ?>" />
    <?php else: ?>
    	<img src="url-to-placeholder" class="placeholder-class" ?>
    <?php endif; ?>

    That way you don’t need the jQuery, as it checks if an image exists/been added if not, uses a fall back to a placeholder image