- Local time
- Aug 2, 2020
I'm currently developing my first WordPress theme and all is going fine. However, I seem to be struggling with outputting attributes of images from the media library. This seems really over complicated?
I finally worked out the alt attribute…
<?php $thumb_id = get_post_thumbnail_id(get_the_ID()); $alt = get_post_meta($thumb_id, '_wp_attachment_image_alt', true); if(count($alt)) echo $alt; ?> alt="<?php echo $alt; ?>"
Although it feels very cumbersome but works. As for the width and height attributes I'm lost :)
Am I approaching this all wrong?
I just want to output alt, width and height!