WordPress.org

Forums

Help with missing ALT attributes! (2 posts)

  1. Erve1879
    Member
    Posted 3 years ago #

    I'm struggling to get the image ALT attributes to appear in my image tags.... This is on a portfolio page which generates thumbnails which in turn link to the full-size versions. Here is the code I am currently using:

    <?php
    /*
    Template Name: GridFolio Portfolio
    */
    ?>
    	<?php get_header(); ?>
    	<noscript>
    			<style>
    				.ib-main a{
    					cursor:pointer;
    				}
    				.ib-main-wrapper{
    					position:absolute;
    					top:0px;
    					bottom:24px;
    					overflow:scroll;
    				}
    
    			</style>
    		</noscript>       
    
    						<div id="ib-main-wrapper" class="ib-main-wrapper">
    							 <div class="ib-main">
    					<?php 
    
    						$category = gf_get_category_id(get_option('gf_portfolio_category'));
    						$categories = get_categories('child_of='.$category);
    						$ppp = 10000;
    						if (get_option('gf_portfolio_nav')) {
    						if (!empty($categories)) {
    							if (isset($_GET[pcat])) {
    								$pcat = $_GET[pcat];
    							}
    							else { $addtoclass = " class=\"active\""; }
    
    					?>
    
    					<div class="portfnav">
    						<ul>
    							<li><span>Filter: </span></li>
    							<li<?=$addtoclass; ?>><a href="<?php echo get_permalink(); ?>">All</a></li>
    							<?php gf_list_portfolio_child_categories($category,$pcat,get_permalink()); ?>
    						</ul>
    					</div>
    								<?php } }?>
    					<?php
    						$category = ($pcat) ? $pcat : $category;
    						$wp_query->query('showposts='.$ppp.'&cat='.$category.'&paged='.$paged);
    								while ($wp_query->have_posts()) : $wp_query->the_post();
    							$do_not_duplicate = $post->ID;
    							$thumb_small= get_post_meta($post->ID, 'thumb-small', true);
    							$thumb_large = get_post_meta($post->ID, 'thumb-large', true);
    							$alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    							if (empty($thumb_small)) { continue; }
    							else { ?>
    													 <article class="data-largesrc"><img src="<?php echo $thumb_small; ?>" data-largesrc="<?php echo $thumb_large; ?>" alt="<?php echo $alt_text; ?>"/><span><?php the_title() ?> </span>
    											 </article>
    								<?php }
    						endwhile;  ?>
    					</div>
    	</div>
    				<?php get_footer(); ?>

    This does not work - the ALT attribute fields are empty in all the images. (I have written the ALT entries into the Media Library!)

    Would be really grateful if someone can tell me where I'm going wrong!

    Thanks in advance

  2. Erve1879
    Member
    Posted 3 years ago #

    Perhaps this post is the wrong forum....?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags