Title: Problem with ALT attribute
Last modified: September 2, 2016

---

# Problem with ALT attribute

 *  [catbegemot](https://wordpress.org/support/users/catbegemot/)
 * (@catbegemot)
 * [12 years ago](https://wordpress.org/support/topic/problem-with-alt-attribute/)
 * I like this theme and have been using it for about two years or so. I host my
   images using Picasa Web gallery and insert link to image into post. Unfortunately,
   there was always a problem with image’s ALT attribute, every time I use ALT the
   image the preview won’t show up on front page. This was because of the way the
   image was pulled from post source – the URL was concatenated with sanitized ALT
   along with width and height attributes. So, instead of [http://example.com/images/abc.jpg](http://example.com/images/abc.jpg)
   you would get [http://example.com/images/abc.jpgAltAttributeHereWidht500Height300](http://example.com/images/abc.jpgAltAttributeHereWidht500Height300)–
   which is exactly why front page preview was broken.
 * If you care to fix this, you need to dig into theme’s functions file (functions.
   php) and locate function the_post_image_url($size=large). Inside it, find the
   following lines:
 *     ```
       } elseif ( $linkedimgurl ) {
       		echo $linkedimgurl;
       ```
   
 * replace the second line (echo… ) with the following:
 *     ```
       $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
       $first_img = $matches [1] [0];
       echo $first_img;
       ```
   
 * This fixed things for me. You can see it working on [http://zealusmedia.com](http://zealusmedia.com)

The topic ‘Problem with ALT attribute’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/autofocus/1.0.1/screenshot.png)
 * AutoFocus
 * [Support Threads](https://wordpress.org/support/theme/autofocus/)
 * [Active Topics](https://wordpress.org/support/theme/autofocus/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/autofocus/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/autofocus/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [catbegemot](https://wordpress.org/support/users/catbegemot/)
 * Last activity: [12 years ago](https://wordpress.org/support/topic/problem-with-alt-attribute/)