Support

Account

Home Forums Front-end Issues Alt-text and images

Solving

Alt-text and images

  • Hello,

    please tell me what is the best/easiest way to show the alt-text when i add images with the advanced custom fields:

    I tried this but it is showing only the images and no alt-text

    ” alt=”<?php echo $alt_text; ?>”>

    Thanks for the help

  • Hi @erni41

    To answer you question I must first know what is the return type you have selected for the image field and what is the full code you are using to render the img

    Thanks
    E

  • Hello,

    the return type is ‘image url’and the full code is:

    <div>
    ” alt=”??”>
    </div>

  • <img class="align-center" src="<?php the_field( 'bild_05' ); ?>" alt="">

  • Hi @erni41

    You have selected image url, so that will prevent you from loading any further data about the image.

    You should select the image object option as this will return the url, caption, and lots more info in an array. Do you know how to use an array? You can see docs for this on the image resource page

    Thanks
    E

  • what happens with the settings when I change the type afterwards ?
    I use a lot of this image fields on the site.

  • Hi @erni41

    The image field will always save the value as an attachment ID. If you change the return type, ACF will continue to load the correct image and return the data type you select in the field’s settings.

    Your code will need to respond to this format.

    Thanks
    E

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

The topic ‘Alt-text and images’ is closed to new replies.