-
-
Hello! We are using the Tower theme (https://mckinneyestateplanning.com)
We have alt tags assigned to all uploaded images via the media library in WordPress, however it seems the theme is not taking those alt tags into account when being added to the home page for certain elements. All images except for the slide images are missing their alt tags. How can we resolve this?
The following are missing their alt tags, which isn’t good for our SEO:The Logo
- The images (posted as media) posted under “Our Estate Planning Process” and “Meet Attorney Charlie Malolo” (2)
- All of the portfolio square images (4)
- All images under Latest Blog (3)
-
Hello,
Sorry but the alt are not set to display. This is our developer’s team choice for the theme. If you want, you can edit theme files to make them display.
Let us know if you need help.Best regards!
-
Interesting. Good to know. What is the best way to adjust the theme to show alt tags?
Thank you!
-
Hello,
The only way is alter theme files and add the function that shows the alt’s.
Make sure to save copies of the changed files in order to replace them again in case of a future theme update.Best regards!
-
I understand that, however you mentioned to ask you for help if needed. What I need to know is where in your theme code does it disallow alt tags, so that I can remove that and thereby allow them.
-
Hello,
It’s not something to remove other than add. You have to add the function that calls the image alt and displays it.
1-Media element:
Go to file vc_templates/media.php and replace the code with the one in this link:
https://codeshare.io/qtAwR2-Portfolio square images:
Go to file includes/view/portfolio/loop-grid.php and replace the code with this:
https://codeshare.io/E3SJA3- Latest Blog:
Go to file vc_templates/latest_blog.php and replace all code with this:
https://codeshare.io/ByPgBBest regards!
-
Thank you for your help so far!
I replaced the code in those three files with the code you supplied. However, it’s still not showing any alt tags on any images on any page. Our homepage has several different images in different elements, and none of them show an alt tag after making the changes to those three files. I’ve cleared my cache and everything, and still, no alt tags.
You can see here: https://mckinneyestateplanning.com
Again, all three of those files were replaced with the exact code you supplied.
-
Hello,
Do you have set the alt text in the image options in Media? The code is tested so there must be something else causing this. Perhaps your host is slow in reflecting the changes made to site.
If you send us your wp credentials in a private reply, we could give it a closer look.
Let us now.Best regards!
-
-
Hello,
I replied you regarding this in this other topic of yours: https://support.codeless.co/forums/topic/too-many-h1-tags-on-front-page/#post-17652
PS: I already reversed all changes made to file style.css.
Best regards!
-
We investigated this more on our own and were finally able to get the alt tags showing for the portfolio images as well as latest blog by adding and tweaking code in the portfolio and loop grid. Hours of searching google and fixing it ourselves.
However any other media uploaded via “media” in visual composer does not show an alt tag yet. It is apparent that this is not an issue with our host or changing the wrong files, but an issue of the right code. Once we inserted the right code it worked for two of those elements.
Still no resolution for adding alt tags to the media images added via the media element in visual composer.
-
Hello,
I see the alt showing in media (screenshot). As for the portfolio items, i already send you the code to change in my replies above (for file includes/view/portfolio/loop-grid.php).
Anyway, i am glad to know everything is as you wanted, now.
Best regards!
-
Hello. It looks like this answer to allowing alt text is specifically for this users images….portfolio square images etc. I’m using Specular and would like all images to have alt text. Please advise.
You should also let new customers know that you do this. Alt text is huge for SEO. I’ve had our site up for months without knowing that all my alt text is missing.
-
Hello,
The hidden replies contain sensitive data such as customer’s private links or login credentials.
The replies where the code edited is shown, is public (screenshot).
The two first links have expired because this is a very old ticket. But basically all you need to do is to get the Atl text using a variable, then add it where ever you need it to show. Below is a part of that code:while (have_posts()) : the_post(); $post_format = get_post_format(get_the_ID()); $post_categories = wp_get_post_categories( get_the_ID() ); $cats = ''; foreach($post_categories as $c){ $cat = get_category( $c ); $cats .= ' '.$cat->name.','; } $alt = get_post_meta(get_post_thumbnail_id(), '_wp_attachment_image_alt', true); $image_title = $attachment->post_title; $caption = $attachment->post_excerpt; $description = $image->post_content; $cats = substr(trim($cats), 0, -1); $output .= '<div class="'.( ($carousel == 'yes')?'':'' ).' blog-article grid-style blog-item '.(($dynamic_from_where == 'one_post')?'single':'').'">'; $output .= '<div class="gridbox">'; $output .= '<div class="media">'; $link = redux_post_meta('cl_redata',get_the_ID() ,'media_post_link'); if($post_format == 'audio'){ $output .= do_shortcode('[soundcloud]'.$link.'[/soundcloud]'); }elseif(get_post_thumbnail_id()){ $output .= '<img src="'.esc_url(codeless_image_by_id(get_post_thumbnail_id(), '', 'url')).'" alt="'.$alt.'">'; // $output .= codeless_image_by_id(get_post_thumbnail_id(), '', 'alt');
From the original code we have added this line:
$alt = get_post_meta(get_post_thumbnail_id(), '_wp_attachment_image_alt', true);
Which gets the Alt text for each post.
Then added the variable in the image tags output:
$output .= '<img src="'.esc_url(codeless_image_by_id(get_post_thumbnail_id(), '', 'url')).'" alt="'.$alt.'">';
See screenshot: https://ibb.co/cHVQGx
Normally this is a customization not included in support. That’s why there is no notification for new users that we do such changes. But since this customer requested it, we tried to help and provide some code.
Best regards!
-
Hello Mihaila – adding the 2 lines of code you supplied should allow the alt text to show for all images correct? What file does the code go into?
-
Hello,
Not for all images in the site. Since some are in the media element, some in portfolio, some in posts. So the code that displays them is also different. But basically the code above is what get’s the alt of an image and displays it.
The above code is for the latest blog: vc_templates/latest_blog.phpYou can edit out the other files (as listed here: https://ibb.co/kjpfic) by following the same way to grab the Alt’s of images.
*Save a backup of edited files as this is not part of theme’s default layout and you will lose the changes in case of future theme update.
Best regards!
-
I updated my media.php file with code you supplied. When I inspect the images on the live site, I’m not seeing the alt text. Here’s the current code with your updates, please advise:
<?php
/**
* Shortcode attributes
* @var $atts
* @var $type
* @var $image
* @var $video
* @var $alignment
* @var $width
* @var $animation
* @var $link
* Shortcode class
* @var WPBakeryShortCode_Media
*/
$output = ”;
$atts = vc_map_get_attributes( $this->getShortcode(), $atts );
extract( $atts );
$output = ‘<div class=”wpb_content_element media media_el animate_onoffset”>’;
$width_style=””;
if($alignment == ‘center’)
$width_style = ‘style=”width:’.$width.’px;position:relative; left:50%; margin-left:-‘.($width/2).’px;” ‘;
if($type == ‘image’){
if(isset($image)){
if(!empty($image)) {
if(strpos($image, “https://”) !== false){
$image = $image;
} else {
$bg_image_src = wp_get_attachment_image_src($image, ‘full’);
$image = $bg_image_src[0];
if(empty($image))
$image = codeless_img_placeholder();
$alt = get_post_meta(get_post_thumbnail_id(), ‘_wp_attachment_image_alt’, true);
}
}
if($link!=”#” && $link!=””)
else
$output .= ‘‘;
$output .= ‘‘;
}
}
if($type == ‘video’){
$output .= ‘<div class=”video_embeded” ‘.$width_style.’>’;
if(isset($video)){
global $wp_embed;
$output .= $wp_embed->run_shortcode(‘[embed class="animation_'.$animation.' video alignment_'.$alignment.' '.$width_style.'"]‘.trim($video).’[/embed]‘);
}
$output .= ‘</div>’;
}
$output .= ‘</div>’;
echo $output;
?>
-
Hello,
I inspected some images and I’m seeing the alt text. See screenshot: https://ibb.co/h9Lwtc
Check them one more time please and let us know.
Best regards!
-
That’s not our website. Our URL is metalpi.com and I’m still not seeing alt text. I really need this issue fixed.
-
Hello,
Sorry for the late reply.
As mentioned since the beginning of this topic, the alt text are not set to display. This is our developer’s team choice for this theme. If you want, you can edit theme files to make them display.
We have already posted several codes along the way to help visitors of this topic get orientated on how to add the alt’s back. Please check them carefully to implement the changes in your site. These are basic wordpress functions you can find in the WordPress repository.
Theme is SEO optimized already and you can further improve it’s seo by installing a plugin such as Yeast.Best regards!
-
I’m not a developer, so without very specific instructions, I’m not sure how to make the code updates. I need to know exact code to add, and which files to add them to.
-
Could we please receive a new update on this topic? Not having alt tags is ridiculous.
-
Hello,
We are going to make an update soon to fix this issue. You can use and third party plugin to do that at the moment.
Regards!
-
You must be logged in to reply to this topic.