1

I'm working off a custom theme which they entirely left out including the alt tag in the img source.

Here is an example of the code:

<img src="<?php echo get_field('image')['sizes']['large']; ?>">

I was searching to find the answer and found this to add, but does not work:

<img src="<?php echo get_field('image')['sizes']['large']; ?>" alt="<?php the_title_attribute(); ?>>">

I'm still pretty much a novice with Wordpress templates. Is there something I'm missing.

1

You are using the Advanced custom fields plugin. The documentation for images: http://www.advancedcustomfields.com/resources/image/

To display the alt-tag for example, you can use this snippet:

$image = get_field('image');

if( !empty( $image ) ) {
    $alt = $image['alt'];
    ...
    echo '<img src="..." alt=" . $alt .">'
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.