Home › Forums › Front-end Issues › can no longer get ALT + Title for images › Reply To: can no longer get ALT + Title for images
After banging away on various solutions, I finally guessed that simply rewriting the array could solve it. Also found some better methods for getting the ALT and TITLE values.
Here’s my code for responsive SEO images with ALT and TITLE tags!
<?php
$image = get_sub_field('photo') ;
$size = '2048x2048';
$alt = get_post_meta($image, '_wp_attachment_image_alt', TRUE);
$img_title = get_the_title($image);
;?>
<?php if( $image ) {
echo wp_get_attachment_image( $image, $size, array('alt'=>$alt), array('title'=>$img_title));
};
?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.