Image problem in Advanced Custom Fields plugin

Asked

Viewed 377 times

2

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

and inserted out of the loop the code:

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

and is returning me the following error:

 15, , foto10, , , image/jpeg, http://localhost/projects/tribuna/wp-content/uploads/2014/04/foto10.jpg, 910, 1283, Array.

1 answer

2

What is returning is not an error. You have configured Field to return an "Image Object". So you are printing a complete object. Note that sometimes out of loop may not work if we do not put the 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 documentation for the image field.


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

echo '<pre>' . print_r( $VARIAVEL_QUE_QUERO_INSPECIONAR, true ) . '</pre>';

Browser other questions tagged

You are not signed in. Login or sign up in order to post.