Home Forums General Issues Add Image field getting URL and array data


Add Image field getting URL and array data

  • I couldn’t find an answer to this so I’m posting this query, apologies if it’s been asked before.

    I’m trying to get just the URL for an image field. I’m getting the URL but I’m also getting a load of array junk too which means my img src tag doesn’t load the image.

    Here’s the code I’m using

    <img src="<?php	the_field('logo_thumbnail', 'product_brand_' . $term->term_id);?>" />

    Which returns this
  • Try this:

    <pre><?php print_r( get_field('logo_thumbnail', 'product_brand_' . $term->term_id) ); ?> </pre>

    This should let you see all of the data within your image field – paste it here if you feel like it.

    Also check your field settings where you add the field to a field group in the ACF admin. There are options for returning Image Object, Image URL, and Image ID – which one do you have selected?

  • Duuuuude!

    Ok I didn’t realise there were image options, and it was set to “Object”. Changing it to Image URL fixed it.

    Total oversight on my part. Thank you kindly for the quick reply!

  • Nice work.. have a great weekend!

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Add Image field getting URL and array data’ is closed to new replies.