Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I need to modify the default gallery code, I need the alt of the image to be the path to the big image. I've modified media.php like this:

function wp_get_attachment_image(...........
'alt'   => $src,
'title' => trim(strip_tags( $attachment->post_title )),
..........

But now my alt is the path to the thumbnail of the image, I need the path to the big one, how can I do that?

Thanks for your time.

share|improve this question
2  
Which problem do you really want to solve? There is probably a better way than to annoy your screen reader users. –  toscho Feb 4 '12 at 6:16

3 Answers 3

This should do the trick

add_filter('wp_get_attachment_image_attributes', 'change_alt_image', 10, 2);

function change_alt_image($attr, $attachment) {

$data_img = wp_get_attachment_image_src($attachment->ID, 'original', false);

    $attr['alt'] = esc_url($data_img[0]);

    return $attr;

}
share|improve this answer

Do you mean [gallery link="file"]
This should work if I understand your question.

share|improve this answer

I am using custom gallery script, in order to work, I need the default code that wordpress gallery generates to be changed so the image alt points the same as the big image url, so when it is clicked, the big image is loaded through the jquery gallery I am using. I managed to modify everything the way I need it but I cannot find what to do so I get the big image as alt value - alt="http://pathtofullsizeimage.com" ... All I managed to do is replace the alt value with $src, but it points to the thumbnail and I need the full image, my php knowledge is extremly poor and I need help to find out what to put instead of $src as value for the alt property in media.php or somewhere else.

Thanks for your time.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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