Home Forums General Issues get image alt in flexible field


get image alt in flexible field

  • Hi!

    i’m having a bit of truble getting this to work – i have read the docs on this site, tried the image field suggestion with the “get image data” on this page:

    i have read into the get_post_meta and only got an error in return :/

    If you have any experience with getting the ALT text from an image in the flexible field – please let me know!

    Thank you 🙂

    • Matt

    • July 12, 2013 at 3:23 pm

    Hi Kenneth,

    It depends how the Image field is setup. I prefer to have the image setup as the Image Object. You can select this when you create the field; return value.

    Then it is as simple as:

    $img = get_field('field_name'); // or use get_sub_field('field_name')
    echo $img['alt'];
    • Elliot

    • July 12, 2013 at 4:37 pm

    Hi @kennethknudsen

    Your problem is that you are using the get_post_meta function instead of the ACF friendly get_field function.

    Please use get_field to allow ACF to format the value correctly

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

The topic ‘get image alt in flexible field’ is closed to new replies.

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.