• Hi there, I have a theme that uses TimThumb to generate thumbnail images on a gallery page. The problem is that image alt tags are not showing for each image on the main gallery pages, see here:

    https://christinecraven.com/gallery/press

    I’ve tried to generate the alt tag by adding a custom field in each post/ portfolio item, called “alt_tag” and then calling it in the category.php file in my theme:

    <div class="imgHentry"><?php the_post_thumbnail( 'thumbnail' ); ?> <strong>alt="<?php echo get_post_meta($att, 'alt_tag', true); ?>"</strong> <div class="linkIcon" style="width:150px; height:150px;"><a href="<?php the_permalink(); ?>" class="goto-icon" style="width:150px; height:150px;"></a></div></div><!-- .imgHentry --><?php
    				} ?>

    It’s not working unfortunately and I’m not sure how to go about this.

    Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Why are you trying to show alt tags? They are not intended to be visible unless the image cannot be displayed.

    Thread Starter gatto26

    (@gatto26)

    1. accessibility for people using screen readers
    2. search engine optimization

    thanks!

    Oh, I guess I’m still not very clear on your question. The alt tags ARE there in the image HTML — so are you trying to access them or display them on the page? Are they not visible as a field when you upload the image?

    Thread Starter gatto26

    (@gatto26)

    Ah, well when I look at the source, for each of the thumbnails the alt tag comes up empty:

    <div class=”imgHentry” style=”width:232px; height:132px; margin-top:7px”>

    <img src=”https://christinecraven.com/wp-content/themes/delight/scripts/timthumb.php?src=https://christinecraven.com/wp-content/uploads/2012/07/nicolelook.jpg&h=130&w=230&#8243; alt=””>
    <div class=”linkIcon” style=”width:232px; height:132px;”>

    Under “src” etc, the alt at the end is empty. alt=””

    I hope it makes sense ??

    Yes, it’s empty, but when you upload images, there is a field to fill that in. Or you should be able to go back to the image in the editor and pull up those fields and fill it in…

    Sorry if I’m being clueless (totally possible — LOL!)

    Thread Starter gatto26

    (@gatto26)

    Yes, but when I do fill them in the tags still come up empty. I tried for a few and unfortunately it did not work. I did some research with the theme developer, and it said that the alt tags dont show up on those main “gallery” pages. Soooo, long story found this stuff about using the custom field, calling the field with the scriipt….hoping to make that work.

    thanks again

    Ah, okay, I was starting to wonder if that might be the case — the thumbnails are not pulling the alt from the main image. Unfortunately, I don’t know enough about coding to help with that. But the other thing you should be aware of is that tim thumb has a history of being very problematic in terms of security (resulting in many hacked sites) — and although the problem was fixed, some servers still won’t let that script or plug-in run. Obviously, that’s not the case for your site, and you may well be fine, but just FYI.

    Also, commercial themes are not generally supported here…so it’s really on the developer to help you with this. Someone may come along who knows enough code to offer you help, but again, just FYI.

    Thread Starter gatto26

    (@gatto26)

    interesting! Ok, well thanks for responding anyway. I am trying too with the developer, and also trying on my own. If I figure it out, I will post the solution here to hopefully help some one else out ?? Here is a link to something that I found that seems like it should work (but currently not for me), just in case there is someone out there needing the same help…

    https://wordpress.stackexchange.com/questions/39501/alt-attributes-not-showing-on-pages

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Retrieving alt_tag attritbute using a custom field’ is closed to new replies.