Custom Alt Tags via PHP file (1 post)

  1. ryschill
    Posted 2 years ago #

    Hey Guys,

    I found a php file where it has in the code alt="" which is making all my posts images not have an alt tag. I'd like to put something within the alt="" that pulls the Alternative Text from the image I'm using in the Media section. Thoughts on how to achieve this?

    To see the code that it currently reads I'll give you this.
    File Name: template-functions.php

    <div id="<?php echo $id; ?>" class="inside-post-slider flexslider">
            <ul class="slides">
                foreach($images as $n=> $img_id){
                    $col = array();
                   // $col['img'] = $img_id;
                    $meta  = $metas[$n];
                    $attachment=wp_get_attachment_image_src($img_id, 'st_normal_thumb');
                    $item = '<li> %1$s </li>';
                    $img = sprintf('<img src="%1$s" alt="" />',$attachment[0]);
                    if(isset($meta['url']) && $meta['url']!=''){
                            $img ='<a href="'.$meta['url'].'">'.$img.'</a></h3>';
                    $caption ='';

Topic Closed

This topic has been closed to new replies.

About this Topic