0

I´m using Snapshot theme from WooThemes.

The code which resizes (width and height and size in kb), and shows the images (an 'a' tag, wrapping an 'img' tag) is this one:

<?php if ( get_option('woo_resize') ) { woo_get_image('image','210','280');?> 

The problem is:

I´ve setted the 'alt' text while posting and, when trying to see the post image source code, the 'alt' attribute, appears, empty.

Does anyone has passed for this before?

Any tips?

The post which I wanted to have the 'alt' attribute is the first product in the first row, in the first column:

http://kevingstongramado.p.ht/catalogo/?cat=28

I´ve tried to insert code manually, without the use of the theme´s functions..

Here´s what I´ve tried:

EDIT (I´ve noticed posting one new post, that the code doesn´t resize in kb):

<?php $img_attr = wp_get_attachment_image_src($attachment->ID, 'image');
$image = wp_get_image_editor($img_attr[0] ); // Return an implementation that   
//extends <tt>WP_Image_Editor</tt>
if ( ! is_wp_error( $image ) ) {
$image->resize(210, 280, true );
$image->save($img_attr[0]);
}
$alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);            
?>
<a href="<?php echo get_permalink($post->ID); ?>" title="View <?php the_title(); ?>">    
<img src="<?php echo get_post_meta($post->ID, "image", $single = true); ?>" alt="<?php 
echo $alt;?>"/></a>

The code doesn´t resize in kb and, still don´t get the 'alt' attribute.

I´ve tried using 'SEO Friendly Images' plugin. Doesn´t work for me.

What should I do?

0

Since the original theme demo image doesn't have any value in alt, I'm assuming there is a bug in the theme you might need to open a ticket for: http://demo.woothemes.com/snapshot/

I don't recommend altering original theme template functions but if you are very far into the project and rather not switch out to another theme, I can suggest few things you can try.

In admin-functions.php of the theme, I'd run var_dump($variable_name); where it relates to the function to see where exactly things get wrong. For example, maybe the thumbnail ID variable is null when trying to retrieve the alt text, and therefore returns the empty string. For example, $thumb_id is used as ID of where function grab the alt text:

if ($alt == '') $alt = esc_attr( get_post_meta($thumb_id, '_wp_attachment_image_alt', true) );

So you run var_dump($thumb_id); right before to see if it even holds the right value. If not, then you can trace where $thumb_id comes from and you can find:

$thumb_id = esc_html( get_post_meta($id,'_thumbnail_id',true) );

And you can var_dump($id); here to see if this one holds the right value. If not, then maybe this $id has been wrong since the beginning:

$id = $post->ID;

Then maybe you can try different method to get post ID such as

$id = get_the_ID();

I hope this will at least help you troubleshoot where the problem occurs in Snapshot and substitute the part with better code or point the problem out to WooThemes for faster support.

  • $attachment is an emptry string, how could I retrive the attachment ID? – Marcelo Noronha May 24 '13 at 12:52
  • Sorry it doesn't look like there is an easy one line fix, you kinda need to play around with altering various parts of code to see what happens. On the other note, the theme was last updated June 2010 and I highly recommend you find other theme. Even if you fix the Alt issue now, other parts of website will break as soon as WordPress decides to change how things are done. – Elisha Terada May 24 '13 at 15:33
  • Well, I could leave this wordpress installation as it is. Since I don´t upgrade this current installation? – Marcelo Noronha May 24 '13 at 18:30
  • What you think? – Marcelo Noronha May 24 '13 at 19:39
  • Sure, alt tag does have some impact on SEO and bit more on accessibility but it's minor if your website is not generating much traffic. – Elisha Terada May 24 '13 at 23:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.