Search code examples
alt

alt attribute malfunction


I have a question regarding the alt text function. alt="" become visible in my Wordpress theme but the value shown is from title field .is that normal ? LE : This link contail the code source of this free expositio theme.It looks like it's made pretty different on the alt/title part.Please watch this part : $strResultGallery .= '<td>'.'<img alt="'.$row_img->post_title.'" src="'.$strThumb.'" />'; $strResultGallery .= '<h5>'.$row_img->post_title.'</h5>'; $strResultGallery .= '</td>'; Here the "magic" happens. If you fill the alt field (from image edit tab), in the source code alt="" will be empty.Instead of this, If we fill the title field (also in the image edit tab) this will appear in the source code as alt attribute (because of img alt="'.$row_img->post_title.'").More than that, <h5>'.$row_img->post_title.'</h5>' will make that alt="" atribute to appear as a title , visible on the page.These things are the same in the demo as well link.Having said that, the code must be rewrited in order to have the functions alt/title in the regular way.If someone can please help , ... Thank you


Solution

  • ok, a really good man gave me the solution.Nice, clean, simple.And for those who want to use this theme and to have alt="" function working properly as well , just replace the img alt="" content found on the tmpl_single.php with this line :

    <img alt="'.get_post_meta($row_img->ID, '_wp_attachment_image_alt', true).'" src="'.$strThumb.'" /> 
    

    . Many thanks to Vlad and also many thanks to Mamaduka the author of this wonderful Wordpress theme