Support » Plugin: Style My Gallery » [Plugin: Style My Gallery] ALT text not being used

Viewing 1 replies (of 1 total)
  • To properly show the alt text, open style-my-gallery.php and replace:

    /**
    		* Add images
    		*/
    		$i = 0;
    		foreach ( $attachments as $id => $attachment ) {
    			$image 		= wp_get_attachment_image_src($id, $size);
    			/* Switch to relative path for Imageflow */
    			if ($style == 'ImageFlow') {
    				$longdesc = $image[0];
    				//$image[0] = str_replace(get_bloginfo('url'),'../../../..',$image[0]);
    			}
    
    			if ($style == 'FlexSlider') $output .= '<li>';
    			$output .= '<img src="' . $image[0] . '" alt="' . $attachment->post_title . '" ';
    			if ($style == 'ImageFlow') $output .= 'width="' . $image[1] . '" height="'. $image[2] . '" longdesc="' . $longdesc . '" ';
    			$output .= '/>' . PHP_EOL;
    			if (($style == 'FlexSlider') && ($attachment->post_content != '')) {
    				$output .= '<p class="flex-caption">' . $attachment->post_content . '</p>' . PHP_EOL;
    			}
    			if ($style == 'FlexSlider') $output .= '</li>' . PHP_EOL;
    
    			/* build separate thumbnail list for users with scripts disabled */
    			$noscript .= '<img src="' . $image[0] . '" width="100px">' . PHP_EOL;
    			$i++;
    		}

    With:

    /**
    		* Add images
    		*/
    		$i = 0;
    		foreach ( $attachments as $id => $attachment ) {
    			$image 		= wp_get_attachment_image_src($id, $size);
    			$alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
    			/* Switch to relative path for Imageflow */
    			if ($style == 'ImageFlow') {
    				$longdesc = $image[0];
    				//$image[0] = str_replace(get_bloginfo('url'),'../../../..',$image[0]);
    			}
    
    			if ($style == 'FlexSlider') $output .= '<li>';
    			$output .= '<img src="' . $image[0] . '" alt="' . $alt . '" ';
    			if ($style == 'ImageFlow') $output .= 'width="' . $image[1] . '" height="'. $image[2] . '" longdesc="' . $longdesc . '" ';
    			$output .= '/>' . PHP_EOL;
    			if (($style == 'FlexSlider') && ($attachment->post_content != '')) {
    				$output .= '<p class="flex-caption">' . $attachment->post_content . '</p>' . PHP_EOL;
    			}
    			if ($style == 'FlexSlider') $output .= '</li>' . PHP_EOL;
    
    			/* build separate thumbnail list for users with scripts disabled */
    			$noscript .= '<img src="' . $image[0] . '" width="100px">' . PHP_EOL;
    			$i++;
    		}

    This will properly display the images alt text rather than showing the attachment title.

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Style My Gallery] ALT text not being used’ is closed to new replies.