Support

Account

Home Forums General Issues Set image alt text using ACF field

Helping

Set image alt text using ACF field

  • How can I set an image’s alt text from an ACF field?

    I tried this https://nimb.ws/VjawAH, but no luck.

    Thanks!

  • Hi @fivehead

    At a guess, you would need to run a hook on post publish/update.

    The hook could then use the get_field value and update the alt.

    You would need to get the image attachment ID and then you can use:

    $image_alt = get_field('image_alt');
    update_post_meta($attachment_id, '_wp_attachment_image_alt', $image_alt);
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.