WordPress.org

Ready to get started?Download WordPress

Forums

Coin Slider 4 WordPress
Add the ALT attribute to each image (1 post)

  1. Boris
    Member
    Posted 3 years ago #

    Hi,
    I'm trying to retrieve the ALT attribute for each image displayed using the Coin-Slider 4 WP plugin. I'm not very experienced in javascript, but I found a lead here:
    how-to-retrieve-alt and here conditional-tag-if-customfield-exists.
    The code I entered into coinslider.php now looks like this:

    if (have_posts()) :
    	    	$out = "<div id='coin-slider'>";
    	    	$i = 0;
    	    	$no = get_option('cs-items') ? get_option('cs-items') : 5;
    	    	$imgField = get_option('cs-image') ? get_option('cs-image') : 'csImage';
    	    	$txtField = get_option('cs-text') ? get_option('cs-text') : 'csText';
    
    	    	while (have_posts() && $i<$no) : 
    
    	    		the_post(); 
    
    	    		$image 		= get_post_meta($post->ID, $imgField , true);
    	    		$text 		= get_post_meta($post->ID, $txtField , true);
    				$alt_text	= $image; get_image_tag($alt);
    
    	    		$permalink 	= get_permalink();
    	    		$thetitle	= get_the_title();
    	    		if ($image != ''){
    	    			$out .= "<a href='$permalink'>
    	    						<img src='$image' alt='$alt_text'/>
    	    						<span>
    									<div class='cs-title-text'>
    	    							<strong>$thetitle</strong><br />
    	    							$text
    									</div>
    								</span>
    	    					</a>
    	    			";
    				}
    
    	      	$i++;
    	      	endwhile;
    	      	$out .= "</div>";
    	    endif;

    I've manually added the $alt_text line, but it's not working. Basically I'm trying to say: take the result of $image (which is the path to the image, retrieved from the csImage field) and use it to retrieve the ALT tag. A few lines below, in the img src part, I call the $alt_text function.

    Does anyone have an idea how I could get those ALT attributes to be used by the browser?
    Thanks!

    http://wordpress.org/extend/plugins/coin-slider-4-wp/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic