Support

Account

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

Solved

Add Image field getting URL and array data

    • udapud

    • July 13, 2013 at 8:58 am

    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

    
    http://site.co.uk/678,%20,%20STARFISH_006,%20,%20,%20http://site.co.uk/wp-content/uploads/2013/07/STARFISH_006.jpg,%20690,%20469,%20Array
    
  • 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?

    • udapud

    • July 13, 2013 at 9:10 am

    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)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.