Skip Navigation

[Escalated to 2nd Tier] Collage gallery block doesn't add ALT attribute to images

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 16 replies, has 2 voices.

Last updated by Waqar 1 year, 1 month ago.

Assisted by: Waqar.

Author
Posts
#2448645

Hi, I've added a Collage gallery block to a Content template for the CPT 'Shights' with a multiple images custom field.

It works fine, but it doesn't add the ALT attribute to the images. The very strange behaviour is that it works fine only in one specific post, but not in the others.

This is the Content template:

/wp-admin/post.php?post=225&action=edit

This is the 'sight' where the ALT is correctly added:

/sight/malin-head/

These are two examples where ALT is not added:

/sight/keem-strand/

/sight/national-wax-museum/

Can you help me?

thanks

#2449393

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting us and I'd be happy to assist.

While I can see the issue of the missing ALT text on some of your 'sight' posts, I couldn't reproduce this on my test website.

This suggests that something specific to your website is involved. Have you checked if deactivating the WPML or other non-Toolset plugins has any effect on this?

Please let me know how it goes and if the issue persists, even with all non-Toolset plugins disabled, I'll need your permission to download a clone/snapshot of the website to investigate this on a different server.

regards,
Waqar

#2449439

Hi Waqar, I tested deactivating plugins. It seems the problem is WPML.

A strange thing is that if I deactivate WPML, then reload one of the Sight without ALTs, it start displaying them. Then, if I activate WPML, that Sight is still displaying ALTs, but another that was not displaying it (and I haven't reloaded while WPML was off), is still not adding ALTs.

You can test with this two SIghts:

/sight/uragh-stone-circle/

/sight/national-wax-museum/

Both of them are not displaying ALTs, you can try to deactivate WPML and reload only one of them.

You can download a clone/snapshot.

Something I haven't told you is that I've added a jQuery that gets the ALT values and use it to display a caption iside the lightbox.

This is the code, it shold not affect in anyway the ALT displaying issue:

jQuery( document ).ready(function() {

  jQuery(".tb-gallery__cell img").click(function(){
    var alt = jQuery( this ).attr("alt");
    jQuery( ".lb-caption" ).text( alt );
    
  });


  jQuery(".lb-next").click(function(){
    
    var src = jQuery(".lb-image").attr("src");
    var alt2 = jQuery('.tb-gallery__cell img[src="'+src+'"]').closest('li').next('li').children().children().children('img').attr("alt");
    jQuery( ".lb-caption" ).text( alt2 );    

  });  
  

  jQuery(".lb-prev").click(function(){
    
    var src = jQuery(".lb-image").attr("src");
    var alt2 = jQuery('.tb-gallery__cell img[src="'+src+'"]').closest('li').prev('li').children().children().children('img').attr("alt");
    jQuery( ".lb-caption" ).text( alt2 );    

  });

});

It is stored in this content template:

/wp-admin/admin.php?page=ct-editor&ct_id=543

cheers

#2450863

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for this update and the permission.

I've downloaded the website's clone and will be running some tests. Will share the findings, as soon as this testing completes.

Thank you for your patience.

#2451713

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for waiting.

During further testing on your website's clone and my test website, I was able to reproduce this issue on a clean test website too.

And, I also noticed that if WPML is deactivated and reactivated again, then the 'alt' text starts showing for the images for the existing posts.

I've shared these findings with the concerned team and will keep you updated through this ticket.

For now, a workaround can be to set the "Sights" post type and its image type custom field "wpcf-all-images" to be translateable and then translate the "alt" text of those images, at the individual "Sights" post edit screen.

#2482499

Hi, I found another WPML ralated bug on the same website. I've a classic view custom archive.

In the Output Editor area I've added a couple of blocks content templates to display taxonomy term title, description and some custom fields with shortcodes.

If I deactivate WPML the content templates output is not displayed. The taxonomy term content is there, also the custom fields are corretly filled.

Actually if I use [wpv-taxonomy-archive] and [types termmeta='description-2'][/types] directly in the custom archive Output Editor area, they are correctly displayed.

is this another bug?

cheers

New threads created by Waqar and linked to this one are listed below:

https://toolset.com/forums/topic/split-wpml-conflicting-with-the-archives-content/

#2483011

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

I've created a separate ticket for your recent report and will follow up on that shortly.
( ref: https://toolset.com/forums/topic/split-wpml-conflicting-with-the-archives-content/ )

For the original issue of this ticket, I have an update to share. As the fix for it is fairly straight forward, it will likely be included in the next release of Toolset plugins.

For now, you can apply the fix, by looking for the following common file, in all the Toolset plugins that you have active:
/vendor/toolset/toolset-common/inc/autoloaded/wpml/WpmlService.php

In this file, at line# 889 you'll see this code:


public function translate_element( $element_id, $element_type = 'post', $return_original_if_missing = true, $lang_code = null ) {
	return apply_filters( 'wpml_object_id', $element_id, $element_type, $return_original_if_missing, $lang_code );
}

And you can replace that with:


public function translate_element( $element_id, $element_type = 'post', $return_original_if_missing = true, $lang_code = null ) {
	if ( is_numeric($element_id) ) {
		return apply_filters( 'wpml_object_id', $element_id, $element_type, $return_original_if_missing, $lang_code );
	} else {
		return $element_id;
	}
}

I hope this helps.

regards,
Waqar

#2518681

Hi Waqar, the fix worked fine for english primary language, but now, we translated to german all the archives and image ALT texts, the alt text is not added to the <img> tag in the secondary german language archives.

you can check it here:
hidden link

I also noticed that the fix wasn't included in the latest version of Toolset plugins. I had to add it again manually after the last update.

cheers

#2525835

Hi Waqar, the fix worked fine for english primary language, but now, we translated to german all the archives and image ALT texts, the alt text is not added to the <img> tag in the secondary german language archives.

you can check it here:
hidden link

I also noticed that the fix wasn't included in the latest version of Toolset plugins. I had to add it again manually after the last update.

cheers

#2526095

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for waiting as we were a little light on the coverage, due to the holidays.

I'm going to perform some more testing and research around this and will get back to you, as soon as I can.

Thank you for your patience.

#2526119
en.png
de.png

Hi Waqar, I also noticed that the html of the map image you can see on these pages is different depending on the language:

english:
hidden link
german:
hidden link

it is rendered in a difefrent way depending on the language (see images). It is a custom image field rendered by a Toolset image block. The ALT attribute is also removed in german.

cheers

#2531737

Hey, any news about this issue?

cheers

#2532639

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you again for waiting as we've been clearing some backlog after the holidays.

I'll be resuming further investigation on this matter today and will share the findings as soon as I can.

#2535399

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for waiting.

I've checked and the fix for the originally reported issue is set to be covered in the upcoming major release, where all Toolset plugins are updated to a newer version, together. That is because this change involves a common file, that is part of multiple Toolset plugins.

I've performed some testing to reproduce the issue with ALT text missing on the archive pages and the difference in the markup of the image tag, but couldn't reproduce this. Can you please share the temporary admin login details of this staging website, so that I can check the involved settings?
( the access details that you previously provided are no longer working )

Note: I'm setting your next reply as private.

#2535477