Created
July 19, 2026 06:16
-
-
Save dhirenpatel22/ae059b41bd0f210a4de0a81d65654aa5 to your computer and use it in GitHub Desktop.
Update image alt text to use media metadata
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| if ( $image_id ) { | |
| $image_alt = get_post_meta( $image_id, '_wp_attachment_image_alt', true ); | |
| $icon_html = wp_get_attachment_image( | |
| $image_id, | |
| $atts['size'], | |
| false, | |
| array( | |
| 'class' => 'product-cat-icon', | |
| 'loading' => 'lazy', | |
| 'alt' => esc_attr( $image_alt ?: $primary_term->name ), | |
| ) | |
| ); | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment