images - How can I add "alt" tag to <picture> element?

admin2025-04-26  8

I am developing my own theme and for logo I use tag:

<?php
   $image_url = get_theme_mod( 'header_logo_image_home', '' );
   $image_id = attachment_url_to_postid($image_url );
?>
   <picture class="lozad" data-src="<?php echo wp_get_attachment_image_src( $image_id, 'logo' )[0]; ?> 1x, <?php echo wp_get_attachment_image_src( $image_id, 'logo-retina' )[0]; ?>  2x" data-alt="====> ? HOW ? <====">
   <source srcset="<?php echo wp_get_attachment_image_src( $image_id, 'logo' )[0]; ?>  1x, <?php echo wp_get_attachment_image_src( $image_id, 'logo-retina' )[0]; ?>  2x">
   </picture>

Is there any way do get ALT based on 'attachment_url_to_postid'?

PS: I use element with lozad.js lazyload script.

Thanks!

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745674141a313487.html

最新回复(0)