Support

Account

Home Forums General Issues get image alt in flexible field

Solving

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: http://www.advancedcustomfields.com/resources/field-types/image/

    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 🙂

  • 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'];
  • 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.