• (Apologies if I just notice this now, my first time rolling ACF image on URL)

    Hello,
    I kind of notice that this:

    <?php if( get_field('image') ): ?>
    
    	<img src="<?php the_field('image'); ?>" />
    
    <?php endif; ?>

    does not work. (The above is an example from the ACF official site Documentation)

    Everytime I do that, I have the UI page editor set the image to URL, and run it up doing “view page” or “preview page” – I get the image URL in text and nothing else, not even the <img> markup was not read.

    So, what’s the get around to this? Do I use something like !empty( the_field('blah') )

    Right now I don’t do a conditional validation for images. I just go straight the_field(‘image’) when I’m triggering a URL.

    https://www.ads-software.com/plugins/advanced-custom-fields/

Viewing 1 replies (of 1 total)
  • Thread Starter Ve Mer

    (@vmercader)

    Nevermind,

    This actually worked better:

    $imgUrl = get_field('image');
     if( !empty($imgUrl) ):
      echo $imgUrl;
     endif;
Viewing 1 replies (of 1 total)
  • The topic ‘ACF – Image get_field vs. the_field’ is closed to new replies.