New to carbon fields -need to add image alt tag
-
Hello -I’ve seen this post but if it does apply to what I’m trying to do I can’t figure it out.
I’m trying to add alt tags to my carbon fields images. There is no image alt tag field so I’ve been trying to add echo the image meta data.
This:
<?php foreach ($team_types as $type_index => $type): $name = $type['title']; $type_image = $type['team_type_icon']; $active_class = ''; if ($type_index == 0) { $active_class = ' class="active"'; } ?> <li <?php echo $active_class; ?> style="background-color:tan;"> <a href="#<?php echo sanitize_title_with_dashes($name); ?>"> <?php echo crb_wp_get_attachment_image($type_image, 'crb_home_tab_icon','alt'); ?> </a> </li>
outputs alt=””
I’m also using this function:
function wp_get_attachment( $attachment_id ) { $attachment = get_post( $attachment_id ); return array( 'alt' => get_post_meta( $attachment->ID, 'wp_attachment_image_alt', true ) ); }
But I’m not getting anywhere. I’m trying to output the image meta data -specifically the alt tag in the media library.
Any ideas?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘New to carbon fields -need to add image alt tag’ is closed to new replies.