Problem with images in the Advanced Custom Fields plugin

2

I am using Advanced Custom Fields in a job and created the following field

and I inserted the code outside the loop:

<?php the_field('jogador_1'); ?>

and is returning the following error:

 15, , foto10, , , image/jpeg, http://localhost/projects/tribuna/wp-content/uploads/2014/04/foto10.jpg, 910, 1283, Array.
    
asked by anonymous 28.04.2014 / 18:35

1 answer

2

What is returning is not an error. You have configured Field to return an "Image Object". Then you are printing a complete object. Note that sometimes out of the loop it may not work if we do not put ID: the_field($meu_field, $post_id) .

One option is to change the setting to "Image URL" and keep your code.

Keeping the current configuration, do:

$imagem = get_field('jogador_1');
var_dump($imagem);
echo '<img src="' . $imagem['KEY-DO-VAR-DUMP'] . '" />';

Or check out the image field documentation .

The var_dump() is a basic debugging technique . I also use the following very much:

echo '<pre>' . print_r( $VARIAVEL_QUE_QUERO_INSPECIONAR, true ) . '</pre>';
    
28.04.2014 / 21:17