Support

Account

Home Forums General Issues Can't get the URL from an image field even with the data ["url"]

Solved

Can't get the URL from an image field even with the data ["url"]

  • Hello!
    I use an image field named “image_artiste”. I used image object in the option. I wanted to use the url of my image that I uploaded before to put the url as a background-image to my li element with this code: <li style="background: url('<?php the_field("image_artiste")["url"]; ?>'); "></li>
    so the_field("image_artiste")["url"] doesn’t work because it gave me the complete array with all the data and not only the url even if a do an echo outsite of my li element. So i’m obligate to use the url option in the return value

    thank!

  • the_field("image_artiste") echos the value of the field '['url'] has no meaning here since the value is not returned. Try echo get_field("image_artiste")["url"]; but I’m not sure this will work or the following which will always work.

    
    $image = get_field("image_artiste");
    echo $image['url'];
    
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Can't get the URL from an image field even with the data ["url"]’ is closed to new replies.