Support » Plugin: Coin Slider 4 WordPress » [Plugin: Coin Slider 4 WordPress] Add the ALT attribute to each image

  • Boris


    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) : 
    	    		$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'/>
    									<div class='cs-title-text'>
    	    							<strong>$thetitle</strong><br />
    	      	$out .= "</div>";

    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?

  • The topic ‘[Plugin: Coin Slider 4 WordPress] Add the ALT attribute to each image’ is closed to new replies.